使用nginx代理了几个系统,采用不同的二级域名,但是每次操作后总是出现提示操作失败,要求重新登录,不知道是不是跟用了websocket有关系,麻烦帮看看如下nginx配置是否有问题。
ngixn配置如下:
server {
listen 80;
server_name ins.test.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location /websocket {
proxy_pass http://ins;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#支持websocket的ws协议,使nginx支持与后端的长连接,http1.1协议才支持,nginx默认是1.0
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location / {
proxy_pass http://ins;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}