我正在尝试配置nginx代理wss,以便使用tomcat作为服务器支持vaadin。
以下是我的当前配置:
location / {
#try_files $uri $uri/ =404;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_max_temp_file_size 0;
proxy_pass http://tomcat/mycontext/;
proxy_read_timeout 300;
# wss
proxy_set_header Connection $http_connection;
proxy_set_header Connection "upgrade";
}
location /mycontext/ {
#try_files $uri $uri/ =404;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_redirect off;
proxy_max_temp_file_size 0;
proxy_pass http://tomcat/mycontext/;
proxy_read_timeout 300;
# wss
proxy_set_header Connection $http_connection;
proxy_set_header Connection "upgrade";
}
上游
upstream tomcat {
server localhost:8080 fail_timeout=0;
}
nginx启动时没有任何投诉,并且在# wss注释后没有这两行代码的情况下可以用于HTTP。
当我尝试连接vaadin时,出现以下错误:
Error in WebSocket connection to wss://myapp.dev/ui/?v-r=push&debug_window
如果有所不同的话,我们正在使用Atmosphere进行wss。