与普通转发差不多,增加了几个参数
location /im
{
proxy_pass http://localhost:9902/;
proxy_http_version 1.1;
proxy_read_timeout 360s;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host:$server_port;
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;
}
保存后,重载配置
nginx -s reload
使用ws:域名/im 访问,转发到服务器9902端口 socket 服务
COMMENTS | NOTHING