最近在看 netty 相关的知识,尝试了在 springboot 中使用 netty ,看的这个博主的文章,https://juejin.cn/post/6844904110576107534 (按照文章搭建的项目) 项目在本地正常启动,网页测试访问本地 ip+port 访问 websocket 正常访问
发现在部署到服务器的时候,无法用域名直接访问 netty 中的 websocket ,而用域名+port(非 80)的方式可以访问
netty 使用的端口是58080,nginx 中的 proxy 也正常,尝试了网上的一些方案,添加了proxy_set_header等,还是无法解决这个问题,麻烦懂得大佬指导一下,感谢
nginx 的配置如下
worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name xx.xx.com; default_type application/octet-stream; #charset koi8-r; #access_log logs/host.access.log main; location /ws { proxy_pass http://127.0.0.1:58080; proxy_read_timeout 120s; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Port $server_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } } 