0

Referring to the following question: Running multiple Node (Express) apps on same port

Can I run multiple apps (backend, api rest) on same port, if I am using strongloop loopback to generates my Node app?

1 Answers1

2

Generally what you will be doing is running multiple instances of your app on different ports and have some sort of load balancer in front switching among the instances and thus exposing it as one port.

Assuming you've started 3 instances on ports 3001, 3002, and 3003, you can do it in nginx like this:

http {
    upstream myloopbackapp {
        server localhost:3001;
        server localhost:3002;
        server localhost:3003;
    }

    server {
        listen 80;

        location / {
            proxy_pass http://myloopbackapp; 
        }
    }
}

Further reading: http://nginx.org/en/docs/http/load_balancing.html

There are equally easy ways to do this in Apache and IIS as well.

SamT
  • 10,374
  • 2
  • 31
  • 39