Report this

What is the reason for this report?

How to run multiple node application with NGINX: same droplet same domain

Posted on July 21, 2014

I followed the tutorial here with node and NGINX. They work great. But, they all are running the node application from the root of the domain.

I have a number of small node apps and I want to be able to run them like:

http://mydomain/app1 http://mydomain/app2

where app1 may be localhost:9000 and app2 is localhost:9001 etc.

when I change my hosts-enabled file from location / to location /app1/

server {
    listen 0.0.0.0:80;
    server_name 192.241.223.202;
    access_log /var/log/nginx/ddApp.log;

    location /app1/ {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header HOST $http_host;
        proxy_set_header X-NginX-Proxy true;

        proxy_pass http://127.0.0.1:9000;
        proxy_redirect off;
    }
}

my application is launched (node sends down the html document) but the browser can’t follow any of the links (load any resources …404’s).

This direct link can get the resouces:

http://192.241.223.202:9000/app/b7672478.app.js

but through the app1 path

http://192.241.223.202/app1/app/b7672478.app.js

NGINX just serves up the root html document.

Actually all requests to the app1 path produce the same response.

The NGINX docs just make my head hurt (as well as my pride).

Any help and direction would be great.

P:)

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.