Using Nginx as a proxy for Node.js

Config file should look like this:

upstream api_domainname {
    server 127.0.0.1:5000;
}
server {
        listen   80;
        server_name  api.domainname.com;

        access_log  /var/log/nginx/api_domainname_access.log;

        location / {
                proxy_pass      http://api_domainname;
                include         /etc/nginx/proxy.conf;
        }
}

Any requests coming in on port 80 for the server name specified will be routed to your NodeJS server.

Leave a Reply

Your email address will not be published. Required fields are marked *