Skip to content

Instantly share code, notes, and snippets.

@houming818
Forked from uorat/nginx-websocket-proxy.conf
Created November 15, 2017 07:15
Show Gist options
  • Save houming818/e7ad667994c9cf9c7df86b091c844c70 to your computer and use it in GitHub Desktop.
Save houming818/e7ad667994c9cf9c7df86b091c844c70 to your computer and use it in GitHub Desktop.
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/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment