Skip to content

Instantly share code, notes, and snippets.

@rjmacarthy
Created December 4, 2014 09:10
Show Gist options
  • Save rjmacarthy/16cf007453424b3658e0 to your computer and use it in GitHub Desktop.
Save rjmacarthy/16cf007453424b3658e0 to your computer and use it in GitHub Desktop.
Node.js Nginx Configuration
upstream app_website {
server 127.0.0.1:3000; // Port your node app is running on
}
# the nginx server instance
server {
listen 80;
server_name website.com;
return 301 http://www.website.com;
}
server {
listen 0.0.0.0:80;
server_name www.website.com website;
access_log /var/log/nginx/website.log;
# Headers and options
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
# Prevents prevents 502 bad gateway error.
proxy_buffers 8 32k;
proxy_buffer_size 64k;
proxy_pass http://app_website;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment