修改nginx配置
1.在service上面添加
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
2.在service里面添加
location /wsapi {
rewrite ^/wsapi/(.*)$ /$1 break;
proxy_pass http://127.0.0.1:24445/agentServer;
proxy_http_version 1.1;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host:$server_port;
}
3.ws写法
ws://127.0.0.1:8080/wsapi/agentServer/

本文介绍了如何在Nginx中配置WebSocket支持,通过添加映射和location块设置,实现了将WebSocket请求代理到127.0.0.1:24445/agentServer的流程。详细步骤包括在service上添加升级映射,以及在location /wsapi下定义WebSocket路径,设置代理头部和超时时间。
2689

被折叠的 条评论
为什么被折叠?



