php - When nginx configures load balancing and sets itself as one of the balancing servers, a 400 error occurs when accessing itself..??
phpcn_u1582
phpcn_u1582 2017-05-16 13:08:15
0
4
492

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

reply all(4)
某草草

Look at the nginx log, is it an infinite loop?

刘奇

This must be an endless loop

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

Didn’t you say it yourself? What do you mean by proxying yourself? Isn’t this an endless loop? Isn’t this an endless loop? Doesn’t the port of the backend and the proxy also conflict?

为情所困

Isn’t that enough if you separate the backend service port and the listening port of the reverse proxy and don’t use the same port? Or you can use server_name to distinguish which server to use. For example, test.com requests 192.168.1.100. Port 80 uses the domain name test.com to access. You write a server using server_name test.com to accept requests. When proxying, use test1.com. Then open a server using server_name test1.com. In this way, the real request and the proxy request are divided into two. Wouldn’t it be separated if we have a server to handle it?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template