請教以下配置有什麼不同?
upstream baidu_server {
server 180.149.132.47:80;
}
server {
listen 80;
server_name xxx.example.com;
charset utf-8;
access_log off;
location / {
proxy_redirect off;
proxy_pass http://baidu_server;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
server {
listen 80;
server_name xxx.example.com;
charset utf-8;
access_log off;
location / {
proxy_redirect off;
proxy_pass http://180.149.132.47:80;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Encoding "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
第二種可以正確跳到百度首頁,第一種卻不行,請問是為什麼?
百度伺服器拒絕,你可以讓設定其他的測試下
兩種都可以。
樓主,我也遇到這個問題,求答案或解決方案,第一種URL直接就變成http://baidu_server了