Configure Nginx to Serve a Node.js Express App

This nginx server block is configured to proxy the node application.
Mind the server port, set to 3300 in this example.

In order to properly run a Node.js application in production,
have a look here

Nginx config for node.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
server {
listen 80;
root /var/www; # trivial here
index index.html; # trivial either
server_name node.site.com

location / {
proxy_pass http://127.0.0.1:3300; # or the server running node
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Fowarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Fowarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
}
}