【问题标题】:How configure multiples process on 443 port? Apache - ubuntu如何在 443 端口上配置多个进程?阿帕奇 - ubuntu
【发布时间】:2021-09-13 17:44:13
【问题描述】:

这是我的问题:

我在服务器上配置了 2 个应用程序。 React(客户端)和 nodejs 后端与它们各自的域。 1 - example1.com 2 - example2.com

我也为每一个都配置了 SSL 证书。当您想在客户端正在运行的同一端口上启动后端时会出现此问题。

是否可以在其上运行 2 个进程?我该怎么做?

这些是我的虚拟主机文件:

example1-le.ssl.conf


<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName example1.com
    ServerAlias www.example1.com
    ServerAdmin info@xample.com
    DocumentRoot /var/www/example1
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


SSLCertificateFile /etc/letsencrypt/live/example1.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example2.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

example1.conf

        ServerName example1.com
        ServerAlias example1.com
        ServerAdmin info@example.com.ar
        DocumentRoot /var/www/example/build

        <Directory "/var/www/example/build">
          RewriteEngine on
         # Don't rewrite files or directories
          RewriteCond %{REQUEST_FILENAME} -f [OR]
          RewriteCond %{REQUEST_FILENAME} -d
          RewriteRule ^ - [L]
           # Rewrite everything else to index.html to allow html5 state links
           RewriteRule ^ index.html [L]
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteCond %{SERVER_NAME} =example1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

另一个也一样。

当我尝试启动第二个项目时,我收到:EADDRINUSE: address already in use :::443

非常感谢您的帮助

【问题讨论】:

  • 您正在寻找“反向代理”。这个词有很多点击率

标签: node.js reactjs apache ubuntu


【解决方案1】:

您不必在同一个端口上绑定 2 个不同的进程。 Olaf Kock 建议的工作正常且易于实现:您将 apache 安装在专用服务器上(或在同一台机器上:没有区别),然后配置反向代理(该模块称为 mod_proxy)。还有其他解决方案(如 haproxy)需要更复杂的配置,但提供更多的配置选项。

【讨论】:

    猜你喜欢
    • 2010-11-12
    • 2015-04-17
    • 2011-03-21
    • 2010-11-15
    • 2020-09-08
    • 2021-03-08
    • 2020-10-10
    • 1970-01-01
    • 2011-10-28
    相关资源
    最近更新 更多