我有一个带有Web套接字的Java应用程序,它通过http://localhost:8080/application之类的tomcat在服务器上的8080端口上运行。但是我在连接到Web套接字时遇到问题,我使用下面的代码在nginx上可以正常工作,并且想要类似的tomcat配置。请记住,我的配置中没有httpd文件,我只是在使用tomcat服务器,因此我想在server.xml中进行配置
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name _;
location / {
include proxy_params;
proxy_pass http://localhost:8080;
proxy_set_header Connection "";
}
location /websocket-stomp/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://localhost:8080;
}
}