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
文件
结果如下:
这是什么情况??求大神解决...
Look at the nginx log, is it an infinite loop?
This must be an endless loop
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?
![](http://img.php.cn/upload/image/000/000/000/d757440fda894067e5f6cd4a1a22643a-0.png)
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?