调整nginx配置,预置socket代理

This commit is contained in:
LiDong 2021-09-02 17:13:41 +08:00
parent 9bd7bef48f
commit 78a03e6149

View File

@ -14,6 +14,9 @@ http {
access_log /var/log/nginx/access.log main; access_log /var/log/nginx/access.log main;
sendfile on; sendfile on;
keepalive_timeout 65; keepalive_timeout 65;
upstream backend {
server midway:7001;
}
server { server {
listen 80; listen 80;
@ -25,7 +28,7 @@ http {
} }
location /api/ location /api/
{ {
proxy_pass http://midway:7001/; proxy_pass http://backend/;
proxy_set_header Host $host; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@ -48,6 +51,42 @@ http {
#expires 12h; #expires 12h;
} }
location /im {
proxy_pass http://backend/im;
proxy_connect_timeout 3600s; #配置点1
proxy_read_timeout 3600s; #配置点2,如果没效,可以考虑这个时间配置长一点
proxy_send_timeout 3600s; #配置点3
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 REMOTE-HOST $remote_addr;
#proxy_bind $remote_addr transparent;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# rewrite /socket/(.*) /$1 break;
proxy_redirect off;
}
location /socket {
proxy_pass http://backend/socket;
proxy_connect_timeout 3600s; #配置点1
proxy_read_timeout 3600s; #配置点2,如果没效,可以考虑这个时间配置长一点
proxy_send_timeout 3600s; #配置点3
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 REMOTE-HOST $remote_addr;
#proxy_bind $remote_addr transparent;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
rewrite /socket/(.*) /$1 break;
proxy_redirect off;
}
location /adminer/ location /adminer/
{ {