WebSocket nginx配置

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 17:56   1530   0

vue + springboot +nginx +WebSocket

spring boot

@Component
@ServerEndpoint("/webSocket/oozieLogSocket")
//此注解相当于设置访问URL
public class WebSocket {}

然后你拦截器要配置一下 "/webSocket/**"

vue

// dev 启动: let socketUrl = 'ws://'+'IP:端口/webSocket/oozieLogSocket'

this.oozieLogSorcket = new WebSocket(socketUrl)

http {

map $http_upgrade $connection_upgrade {

default upgrade;

'' close;

}

server {
listen 80;
server_name localhost;


location /FDSOC {

add_header 'Access-Control-Allow-Origin' '*';

try_files $uri $uri/ /index.html = 404;

proxy_pass http://server;

proxy_set_header Upgrade $http_upgrade;

proxy_set_header Connection $connection_upgrade;

proxy_read_timeout 36000s;

proxy_send_timeout 36000s;

}

}

}

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP