nginx / nodejs stack setup

Mon Feb 17, 2014

So when you have an nginx + nodejs combo, you want to use nginx to port foward to nodejs

my nodejs uses forever to run on port 3000.

here is the nginx config setup

sudo vi /etc/nginx/site-enabled/default

#add this line before server { ... }
upstream app_nodejs {
        server localhost:3000;

#now in server {...}, assuming you want to map your url root to point to nodejs
location / {
               proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
               proxy_set_header Host $http_host;
               proxy_set_header X-NginX-Proxy true;

               proxy_pass http://app_nodejs;
               proxy_redirect off;