Skip to content

Instantly share code, notes, and snippets.

@anmsid
Created May 31, 2014 13:44
Show Gist options
  • Save anmsid/a73a4114e8047793c653 to your computer and use it in GitHub Desktop.
Save anmsid/a73a4114e8047793c653 to your computer and use it in GitHub Desktop.
NodeJS + Socket.IO app served through Nginx proxy
# Node JS app backend
upstream node_server {
server 127.0.0.1:3003;
}
server {
server_name app.example.com;
#forward to NodeJS app
location / {
proxy_pass http://node_server;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#websocket support
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
}
#server static contents
location ~* ^(?!/socket.io/).*\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm|svg|woff)$ {
root /home/www/node-app/public;
expires 30d;
access_log off;
}
location ~ /\.(ht|git) {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment