nginx.conf
設定檔
upstream test.com {
# ip_hash;
server 127.0.0.1:80 weight=10;
#server 192.168.1.116:80 weight=1;
#server 116.62.19.122:80 weight=1;
}
server {
listen 80;
server_name test.com;
root /var/Website/Test;
index index.php index.html index.htm;
charset utf-8;
location / {
proxy_pass http://test.com;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
try_files $uri $uri/ /index.php?$query_string;
autoindex on;
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:8000;
fastcgi_split_path_info ^(.+\.php)(/?.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
include fastcgi_params;
}
}
hosts
檔案
結果如下:
這是什麼情況? ?求大神解決...
为情所困2017-05-16 13:10:15
你把後端服務端口和反向代理的監聽端口區分開不要用同一個端口,不就可以了麼
或者用server_name去區分走哪個server也行啊
比如test.com 請求到192.168.1.100的80埠使用的是網域test.com訪問,你寫一個server用server_name test.com來接受請求,代理的時候用test1.com 然後在開一個server用server_name test1.com這樣子真實請求和代理請求由兩個server去處理不就分開了麼