Skip to content

Instantly share code, notes, and snippets.

@bsphere
Last active December 10, 2015 22:28
Show Gist options
  • Save bsphere/4501965 to your computer and use it in GitHub Desktop.
Save bsphere/4501965 to your computer and use it in GitHub Desktop.
Nginx site configuration for Node.js app
upstream myapp_upstream {
server 127.0.0.1:3000;
keepalive 64;
}
server {
listen 8080;
server_name myapp.com;
return 301 $scheme://www.myapp.com$request_uri;
}
server {
listen 8080;
server_name www.myapp.com;
error_page 400 404 500 502 503 504 /50x.html;
location /50x.html {
internal;
root /usr/share/nginx/www;
}
location ~ ^/(images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico|home/|html|xml) {
root /home/ubuntu/myapp/public;
access_log off;
expires max;
}
location / {
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_http_version 1.1;
proxy_pass http://myapp_upstream;
proxy_intercept_errors on;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment