简体   繁体   English

我可以在同一端口上运行多个loopback.io应用程序吗?

[英]Can I run multiple loopback.io apps on same port?

Referring to the following question: Running multiple Node (Express) apps on same port 引用以下问题: 在同一端口上运行多个Node(Express)应用程序

Can I run multiple apps (backend, api rest) on same port, if I am using strongloop loopback to generates my Node app? 如果我正在使用Strongloop回送生成我的Node应用程序,那么我可以在同一端口上运行多个应用程序(后端,api rest)吗?

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: 假设您已经在端口3001、3002和3003上启动了3个实例,则可以在nginx中执行以下操作:

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 进一步阅读: http : //nginx.org/en/docs/http/load_balancing.html

There are equally easy ways to do this in Apache and IIS as well. 在Apache和IIS中也有同样简单的方法可以做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM