nginx 配置 nodejs socket.io 反向代理

nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
server {
listen 9985;
server_name localhost;
location ^~ / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;

proxy_pass http://localhost:9988; # nginx需要反向代理的目标链接

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

socket.io更多服务器的反向代理参考官方文档 https://socket.io/docs/v4/reverse-proxy/

本文由 linx(544819896@qq.com) 创作,采用 CC BY 4.0 CN协议 进行许可。 可自由转载、引用,但需署名作者且注明文章出处。本文链接为: https://blog.jijian.link/2023-03-25/nginx-nodejs-socket.io/

如果您觉得文章不错,可以点击文章中的广告支持一下!