Springboot使用外置tomcat的同时使用websocket通信遇到的坑

随意门:https://blog.csdn.net/qq_43323720/article/details/99660430

另外,使用了nginx的话,需要注意开放websocket支持

    server {
        listen       8866;      # 这里用的8866端口
        server_name  ****************;

        location / {
            proxy_pass   http://********;  # 代理路径
            index  index.html index.htm;
			
		# 获取真实ip地址
		proxy_set_header Host $host:8866;    # 注意保持一致
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header REMOTE-HOST $remote_addr;

		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        	proxy_read_timeout   3600s;
        	# 启用支持websocket连接
        	proxy_set_header Upgrade $http_upgrade;
        	proxy_set_header Connection "upgrade";

        }
    }

  

原文地址:https://www.cnblogs.com/skyLogin/p/11532556.html