簡體   English   中英

在不同的端口上部署兩個不同的應用程序

[英]Deploy two different apps on different ports

這個問題很簡單。 兩人如何在 ubuntu 20 遠程服務器上部署兩個不同的 Nodejs 應用程序。 App1 應訪問 throw http://ip-address:8080,第二個 App 應部署在 http://ip-address:8081 上。 這兩個應用程序始終可以從 localhost 訪問。 我的 web 服務器是 apache 並且這兩個端口在防火牆中被禁用。

所以ufw status返回低於結果

Status: active

To                         Action      From
--                         ------      ----
8080                       ALLOW       Anywhere
8081                       ALLOW       Anywhere
80                         ALLOW       Anywhere
8080 (v6)                  ALLOW       Anywhere (v6)
8081 (v6)                  ALLOW       Anywhere (v6)
80 (v6)                    ALLOW       Anywhere (v6)

我的 apache2 配置為反向代理,如下所示:

<VirtualHost *:80>

    ProxyPreserveHost On

    ProxyPass / http://127.0.0.1:8080/
    ProxyPassReverse / http://127.0.0.1:8080/

    ProxyPass / http://127.0.0.1:8081/
    ProxyPassReverse / http://127.0.0.1:8081/

    ServerAdmin admin@example.com
    DocumentRoot /var/www/html
    <Directory /var/www/html>
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

通過為這兩種情況提供直接路徑,您會混淆 Apache。 apache 如何知道哪個請求應該重定向到哪個端口?

回答:

ProxyPass /app1 http://127.0.0.1:8080/
ProxyPassReverse /app1 http://127.0.0.1:8080/

ProxyPass /app2 http://127.0.0.1:8081/
ProxyPassReverse /app2 http://127.0.0.1:8081/

我希望相信如果有其他配置,這應該可以解決您的問題。 應相應地調查任何進一步的錯誤

您可以使用:

ProxyPass /app1 http://localhost:8080/app1
ProxyPassReverse /app1 http://localhost:8080/app1

ProxyPass /app2 http://localhost:8081/app2
ProxyPassReverse /app2 http://localhost:8081/app2

暫無
暫無

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

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