Skip to content

Instantly share code, notes, and snippets.

@boutell
Created December 7, 2014 17:00
Show Gist options
  • Save boutell/e2acfca73490f1328242 to your computer and use it in GitHub Desktop.
Save boutell/e2acfca73490f1328242 to your computer and use it in GitHub Desktop.
nginx reverse proxy for node app in which nginx serves static files directly. Also multiprocess-ready with round robin load balancing.
upstream upstream-EXAMPLE {
server localhost:3000;
# To use additional cores, edit your data/port file
# to read 3000 3001 3002 3003, and list the rest
# of them here too (commented out in this example).
# Your site will listen on one port per process
# automatically. Requires latest deployment files
# as found in sandbox
#server localhost:3001;
#server localhost:3002;
#server localhost:3003;
}
server {
listen 80;
server_name localhost EXAMPLE.com EXAMPLE-prod.punkave.net;
client_max_body_size 32M;
access_log /var/log/nginx/EXAMPLE.access.log;
error_log /var/log/nginx/EXAMPLE.error.log;
location / {
gzip_types text/css text/javascript image/svg+xml
application/vnd.ms-fontobject application/x-font-ttf text/html;
root /opt/stagecoach/apps/EXAMPLE/current/public;
try_files $uri @proxy-EXAMPLE;
}
location @proxy-EXAMPLE {
proxy_pass http://upstream-EXAMPLE;
proxy_next_upstream error timeout invalid_header http_500 http_502
http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment