Wednesday 8 January 2020

nginx config for node.js app

server {
        listen 80 default_server;
        listen [::]:80 default_server;
        root /var/www/html;
        server_name _;
    location / {
        root /data/frontend;
        try_files $uri $uri/ /index.html;
    }
        location /api {
        proxy_pass http://localhost:5000;
    }
    location /socket.io {
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_pass http://localhost:5000;
    }
}