Nginx Reverse Proxy for WebSocket
upstream websocket {
server localhost:3000;
}
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/websocket.access.log main;
location /socket.io/ {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /socket.io/socket.io.js {
proxy_pass http://websocket;
}
location /sample.html {
root /usr/share/nginx/html/;
}
}