nginx tomcat websocket 连接拒绝

背景: 基于nginx 、tomcat(多个服务)、websocket 前提下,进行通知。

            nginx 版本:nginx version: nginx/1.14.1

前提:tomcat 处于运行中,只修改 nginx 支持websocket 配置。

一、配置文件如下

在nginx.conf 文件中,  http -> server 中 添加配置:

location /wss {
             proxy_pass  http://server-name; #ip + 端口,或者是你自定义的 upstream
             proxy_http_version 1.1;
             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;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "Upgrade";
}

二、重新加载配置文件

1.问题:发现 连接还是拒绝。

   解决过程: 查看 nginx的 errror.log 日志,发现 111: Connection refused  拒绝的日志

   答案: 重新启动tomcat, 发现websocket 连接成功


版权声明:本文为qq_38347917原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。