node.js - 如何在 443 端口上配置多个进程? Apache - ubuntu

标签 node.js reactjs apache ubuntu

这是我的问题:
我在服务器上配置了 2 个应用程序。 React(客户端)和 nodejs 后端与它们各自的域。
1 - example1.com
2-example2.com
我也为每一个都配置了 SSL 证书。当您想在客户端正在运行的同一端口上启动后端时,就会出现此问题。
是否可以在其上运行 2 个进程?我该怎么做?
这些是我的虚拟主机文件:
示例 1-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>

示例1.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
非常感谢你的帮助

最佳答案

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

关于node.js - 如何在 443 端口上配置多个进程? Apache - ubuntu,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68213852/

相关文章:

无法识别 CURL apache 模块中的自定义 header

javascript - Mongoose - 保存模型数组并 promise 全部

c# - Azure WebJob 访问被拒绝

reactjs - 设置 vite --template React 和 eslint (airbnb)

javascript - 无法使用react useState更新状态

javascript - 横向图例 React-vis

linux - 一个一般的 linux 文件权限问题 : Apache and WordPress

ruby-on-rails - 让 Rails 3 和 Passenger 在 CentOS 5.4 上工作 - Apache 错误

arrays - 如何在 NodeJS 中读取缓冲区的前 n 个字节并将其转换为字符串?

javascript - Node 14 : Import modules using an absolute path for native ES6 module