nginx.conf
設(shè)定檔
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
檔案
結(jié)果如下:
這是什麼情況? ?求大神解決...
你自己不是說(shuō)了嘛,自己代理自己是什麼意思哦,自己接收個(gè)請(qǐng)求再給自己,這不死循環(huán)嗎,再者後臺(tái)和代理的端口一樣不衝突嗎?
你把後端服務(wù)端口和反向代理的監(jiān)聽端口區(qū)分開不要用同一個(gè)端口,不就可以了麼
或者用server_name去區(qū)分走哪個(gè)server也行啊
比如test.com 請(qǐng)求到192.168.1.100的80埠使用的是網(wǎng)域test.com訪問(wèn),你寫一個(gè)server用server_name test.com來(lái)接受請(qǐng)求,代理的時(shí)候用test1.com 然後在開一個(gè)server用server_name test1.com這樣子真實(shí)請(qǐng)求和代理請(qǐng)求由兩個(gè)server去處理不就分開了麼