Configuration for nginx.conf needed to proxy the node.js server
All you need to run the node.js through Nginx is to proxy the server port and allow websocket connection. The following example shows a basic setup:
Copy
daemon off;
worker_processes 1;
events {
worker_connections 4096;
}
http {
# Websocket proxying
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
location / {
proxy_pass http://127.0.0.1:{NODEJS_SERVER_PORT};
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
}