简体   繁体   English

如何使用不同的端口部署多个nodeJS应用程序

[英]How to deploy multiple nodeJS application with different port

I'm rather new to NodeJS and I'd like to deploy the API and the application on the same server, which means same IP but on different ports. 我不是NodeJS的新手,我想将API和应用程序部署在同一服务器上,这意味着相同的IP,但是在不同的端口上。

From different search I saw it's possible but I don't know how. 从不同的搜索中,我看到了可能,但我不知道如何。 Can I use Restify for this redirection ? 我可以使用Restify进行此重定向吗?

in this code app.listen(PORT HERE); 在此代码中app.listen(PORT HERE); on your two apps just define a different ports for each one. 在您的两个应用程序上,只需为每个应用程序定义一个不同的端口。

For example 例如

in App1 = app.listen(3000); 在App1 = app.listen(3000);
in App2 = app.listen(8000); 在App2 = app.listen(8000);

then to access each one is like : 然后访问每个就像:

App1 = http://localhost:3000 App1 = http:// localhost:3000
App2 = http://localhost:8000 App2 = http:// localhost:8000

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

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