Monday 29 May 2017

NGINX server with 2 NodeJS Apps

I will make it short without introductions ..

I'm having a serious issues with NGINX configuration (on google cloud) to make 2 nodejs apps working on the same domain with different PORTS

let's say app1 is working on port 3002, app2 working on port 3003

app1

    location / {
        root /home/bitnami/project_name;
        proxy_pass http://127.0.0.1:3002;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_redirect off;
    }

app2

   location /app2 {
        root /home/bitnami/project_name;
        proxy_pass http://127.0.0.1:3003;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_redirect off;
    }

when I surf www.example.com/app2, I get 404 page

I know some of u will say that this Q has been asked before, believe me I've tried all possible solutions on stackoverflow .. non has worked with me

Note: app1 location it has to be the main domain so (/) the main domain URL without path



via developerbh

No comments:

Post a Comment