Nginx代理Websocket端口配置
1、加入Nginx代理配置
#WS和Http协议转换
map $http_upgrade $connection_upgrade {
default keep-alive;
'websocket' upgrade;
}
server {
#WS端口-需要代理的端口
listen 1111;
server_name localhost;
#路径配置-WS后缀
location /websocket {
#目标地址
proxy_pass http://127.0.0.1:80/websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}
2、重启Nginx
#Nginx相关命令
systemctl stop nginx
systemctl start nginx
systemctl restart nginx
#查看监听端口
netstat -anp|grep 您的端口