centos7 nginx反向代理无法访问 502
配置如下,主要就是两个server_name 不同,*.x.com, a.x.com
代理分别不同的后端服务器,http://139.x.x.x:8090/admin(腾讯云服务器) 是可以访问的,而 a.x.com/admin 访问,返回的始终是502,很奇怪,
而*.x.com/admin(阿里云服务器) 都是可以访问到的server {
listen 443 ssl http2;
ssl on;
ssl_certificate /usr/local/nginx/ssl/*.x.com.key.pem;
ssl_certificate_key /usr/local/nginx/ssl/*.x.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name a.x.com;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/mall/dist;
index index.html index.htm index.php;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
#将请求转发到admin
location /admin {
root html;
proxy_pass http://139.x.x.x:8090/admin;
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_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100m;
index index.html index.htm;
} }server {
listen 443 ssl http2;
ssl on;
ssl_certificate /usr/local/nginx/ssl/*.x.com.key.pem;
ssl_certificate_key /usr/local/nginx/ssl/*.x.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name *.x.com;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/mall/dist;
index index.html index.htm index.php;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
#将请求转发到admin
location /admin {
root html;
proxy_pass http://127.0.0.1:8090/admin;
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_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100m;
index index.html index.htm;
} }
配置如下,主要就是两个server_name 不同,*.x.com, a.x.com
代理分别不同的后端服务器,http://139.x.x.x:8090/admin(腾讯云服务器) 是可以访问的,而 a.x.com/admin 访问,返回的始终是502,很奇怪,
而*.x.com/admin(阿里云服务器) 都是可以访问到的server {
listen 443 ssl http2;
ssl on;
ssl_certificate /usr/local/nginx/ssl/*.x.com.key.pem;
ssl_certificate_key /usr/local/nginx/ssl/*.x.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name a.x.com;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/mall/dist;
index index.html index.htm index.php;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
#将请求转发到admin
location /admin {
root html;
proxy_pass http://139.x.x.x:8090/admin;
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_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100m;
index index.html index.htm;
} }server {
listen 443 ssl http2;
ssl on;
ssl_certificate /usr/local/nginx/ssl/*.x.com.key.pem;
ssl_certificate_key /usr/local/nginx/ssl/*.x.com.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name *.x.com;
access_log /data/wwwlogs/access_nginx.log combined;
root /data/mall/dist;
index index.html index.htm index.php;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
#将请求转发到admin
location /admin {
root html;
proxy_pass http://127.0.0.1:8090/admin;
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_set_header X-Forwarded-Proto $scheme;
client_max_body_size 100m;
index index.html index.htm;
} }
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货