简体   繁体   English

在子域中托管多个节点app.js

[英]Hosting multiple node app.js in a sub-domain

Is there a way i can host multiple nodejs app.js on single port for multiple tenancy? 有没有一种方法可以在单个端口上托管多个nodejs app.js以实现多租户? Either in Docker or in vps 在Docker或vps中

Each tenant can only access his/her folder containing his/her app.js. 每个租户只能访问包含他/她的app.js的文件夹。

I wanted to create a package inside node_module and create multiple customers workspace folders inside the package and be importing the matched subdomain hostname request with customer workspace from main nodejs and whereby activating wild subdomain like *.mainDomain.com But i think this might look silly because customer workspace inside node_module might not look safe 我想在node_module内创建一个程序包,并在该程序包内创建多个客户工作区文件夹,并从主nodejs导入与客户工作区匹配的子域主机名请求,从而激活* .mainDomain.com之类的野生子域,但是我认为这看起来很愚蠢,因为node_module内的客户工作区可能看起来不安全

You cannot use the same port for multiple node.js applications but you can look at leveraging nginx. 您不能将相同的端口用于多个node.js应用程序,但是可以利用nginx。 You can configure nginx to listen on one port for multiple domain names and then redirect requests to the IP and port of the respective node.js application. 您可以将nginx配置为在一个端口上侦听多个域名,然后将请求重定向到相应的node.js应用程序的IP和端口。

This link might help you to achieve it: https://serverfault.com/questions/536576/nginx-how-do-i-forward-a-http-request-to-another-port 该链接可以帮助您实现: https : //serverfault.com/questions/536576/nginx-how-do-i-forward-a-http-request-to-another-port

Is there a way i can host multiple nodejs app.js on single port for multiple tenancy? 有没有一种方法可以在单个端口上托管多个nodejs app.js以实现多租户? Either in Docker or in vps 在Docker或vps中

You cannot have more than one applications listening on the same port on a single machine. 一台计算机上的同一端口上侦听的应用程序不能超过一个。 If you want to route traffic from a single port to more than one applications or dockers you would need an application to listen on a port an decide where to route the incoming request every time. 如果要将流量从单个端口路由到多个应用程序或docker,则需要一个应用程序侦听端口并决定每次将传入请求路由到何处。 Each of the rest of the application would have to listen to a different port of the host machine. 应用程序的其余每个部分都必须侦听主机的不同端口。

As for the second part of your question, I think it quite clear what you are trying to do. 至于问题的第二部分,我想很清楚您正在尝试做什么。 What is the main nodejs , and why would you create a folder inside node_modules ? main nodejs是什么,为什么要在node_modules内创建一个文件夹?

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

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