[英]Socket.io with NGINX. Unable to do configurations for sockets to work
我的后端是 socket.io,我想用 nginx 配置 socket.io。在 nginx 以下配置之后,我可以使 sockets 以外的路由正常工作,但我的 sockets 不工作。
服務器名稱 yourdomain.com www.yourdomain.com;
location / {
proxy_pass http://localhost:5000; #whatever port your app runs on
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
我需要在 (sudo nano /etc/nginx/sites-available/default) 文件中做什么配置才能使 sockets 工作。
您是否嘗試添加
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
到你的位置配置?
參見https://www.nginx.com/blog/nginx-nodejs-websockets-socketio
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.