php - nginx 設定負載平衡的時候,設定自身也為均衡伺服器之一時,存取自身時 400 錯誤..??
phpcn_u1582
phpcn_u1582 2017-05-16 13:08:15
0
4
493

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檔案

結果如下:

這是什麼情況? ?求大神解決...

phpcn_u1582
phpcn_u1582

全部回覆(4)
某草草

你看看nginx日誌,是不是死循環了

刘奇

這一定是死循環了

/var/log 下面找找
世界只因有你

你自己不是說了嘛,自己代理自己是什麼意思哦,自己接收個請求再給自己,這不死循環嗎,再者後台和代理的端口一樣不衝突嗎?

为情所困

你把後端服務端口和反向代理的監聽端口區分開不要用同一個端口,不就可以了麼
或者用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去處理不就分開了麼

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板