簡體   English   中英

我可以在一個域下上傳多個node.js應用程序嗎?

[英]Can I upload multiple node.js apps under one domain?

我使用DreamHost作為提供程序,並且有一個VPS計划,允許我上載nodejs應用程序。 但是,我希望能夠在一個域下擁有多個小型應用,例如

www.example.com/app1
www.example.com/app2
www.example.com/app3

Node.js是否可能?

您不能在單個端口上運行多個應用程序,但可以在不同的端口上運行它們,並可以使用以下端口訪問它們:

www.example.com //app1 (default http port is 80 and default https port is 443 hence you don't need to specify port for the apps using port 80) www.example.com:3000 //app2

您不能在單個端口上運行多個應用程序。 但是我們可以在其他端口上運行應用程序,並使用nginx將網址重定向到正確的應用程序,例如

server {
  listen 80;
  root /var/www;
  server_name www.example.com;

location /app1 {
    proxy_pass http://localhost:{port}; // app1 server Comment 1
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}

location /app2 {
    proxy_pass http://localhost:{port};  // app2 server Comment 2
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection 'upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
}
}

這會將www.example.com/app1重定向到app1服務器,並將www.example.com/app2重定向到app2服務器。 見評論1和2。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM