NGINX突然将所有内容重定向到主域
经过数周的完美工作,NGINX开始将所有内容重定向到主域。我将其设置为将数字子域代理到一个特定端口,如:5555.example.com->example.com:5555。NGINX版本未更新,配置文件也未更改,但现在,所有子域都被重定向到主域(5555.example.com立即更改为example.com,我到达主域) 下面是/etc/nginx/nginx.conf的内容:NGINX突然将所有内容重定向到主域,nginx,Nginx,经过数周的完美工作,NGINX开始将所有内容重定向到主域。我将其设置为将数字子域代理到一个特定端口,如:5555.example.com->example.com:5555。NGINX版本未更新,配置文件也未更改,但现在,所有子域都被重定向到主域(5555.example.com立即更改为example.com,我到达主域) 下面是/etc/nginx/nginx.conf的内容: user nginx; worker_processes 1; error_log /var/log/ngi
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
keepalive_timeout 65;
server {
listen [::]:80;
listen 80;
server_name "~^(www\.)?(?<port_subdomain>\d{4})\.example\.com$";
location / {
resolver 10.33.1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_pass http://example.com:$port_subdomain;
}
}
server {
listen [::]:80;
listen 80;
server_name ~^(www\.)?example\.com$;
location / {
resolver 10.33.1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_http_version 1.1;
proxy_pass http://example.com:8502;
}
}
}
我明白了
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
日志中有一个错误,但从我看到的情况来看,自从我安装NGINX以来,该错误一直出现:
connect() failed (111: Connection refused) while connecting to upstream,
client: XXX.XX.XXX.XX, server: ~^(?<port_subdomain>[0-9]*)\.example\.com$,
request: "GET /socket.io/?EIO=3&transport=polling&t=LPZb6nq HTTP/1.1",
upstream: "http://XX.XX.X.XX:5555/socket.io/?EIO=3&transport=polling&t=LPZb6nq",
host: "5555.example.com", referrer: "http://5555.example.com/"
连接到上游时,connect()失败(111:连接被拒绝),
客户端:XXX.XX.XXX.XX,服务器:~^(?[0-9]*)\.example\.com$,
请求:“GET/socket.io/?EIO=3&transport=polling&t=LPZb6nq HTTP/1.1”,
上游:“http://XX.XX.X.XX:5555/socket.io/?EIO=3&transport=polling&t=LPZb6nq",
主持人:“5555.example.com”,推荐人:http://5555.example.com/"
为什么您认为重定向来自nginx,而不是您的上游?我正是这么想的。我没有访问上游服务器的权限,试图通过sys admins atm解决问题。这当然不是nginx的问题,因为在您的配置中没有任何东西可以发出重定向。为什么您认为重定向来自nginx,而不是来自您的上游?这正是我开始思考的。我无法访问上游服务器,试图通过sys admins atm解决问题。这当然不是nginx的问题,因为您的配置中没有任何东西可以发出重定向。
connect() failed (111: Connection refused) while connecting to upstream,
client: XXX.XX.XXX.XX, server: ~^(?<port_subdomain>[0-9]*)\.example\.com$,
request: "GET /socket.io/?EIO=3&transport=polling&t=LPZb6nq HTTP/1.1",
upstream: "http://XX.XX.X.XX:5555/socket.io/?EIO=3&transport=polling&t=LPZb6nq",
host: "5555.example.com", referrer: "http://5555.example.com/"