我的后端是socket.io,我想用nginx配置socket.io。在nginx下面的配置之后,我可以使我的路由而不是套接字工作,但我的套接字不工作。
server_name 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)文件中进行哪些配置才能使套接字工作。
发布于 2020-08-29 13:25:02
你有没有试着添加
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
添加到您的位置配置?
请参阅https://www.nginx.com/blog/nginx-nodejs-websockets-socketio
https://stackoverflow.com/questions/63646741
复制相似问题