Apache ReverseProxy不适用于节点和SSL

问题描述 投票:0回答:1

我正在尝试在Web服务器上的HTTPS上设置我的应用程序。我有使用AutoSSL在InMotion主机上安装的有效证书。我的Centos服务器上的端口3000上运行了节点应用程序,而端口443上的apache SSL服务器上运行了节点应用程序。为了将请求路由到我的网站,我试图创建一个反向代理。我制作了一个名为default-site.conf的文件,该文件存储在/etc/http.d/conf.d中,并且具有以下内容:

<VirtualHost _default_:443>
    SSLProxyEngine on

    ServerName example.com
    ServerAlias www.example.com 

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyVia Full
    <Proxy *>
      Require all granted
    </Proxy>

    ServerAdmin [email protected]
    DocumentRoot /home/USER/my-app/public

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    SSLCertificateFile  /home/USER/ssl/certs/certificate.crt
    SSLCertificateKeyFile /home/USER/ssl/keys/certificate.key


    ProxyPass / https://example.com:3000/
    ProxyPassReverse / https://example.com:3000 /

    <Directory "/home/USER/my-app/public">
        AllowOverride All
    </Directory>        

</VirtualHost>

[我会强调指出,该应用程序可以通过http://example.com:3000访问(不安全),但是当我尝试转到https://example.com(安全)时,我得到了带有404错误的空白index.html:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (index.js, line 0)

node.js apache reverse-proxy
1个回答
0
投票

我设法通过将配置完全简化为以下两行来解决此问题:

ProxyPass / http://127.0.0.1:3000/
ProxyPassReverse / http://127.0.0.1:3000/

这可能不是最灵活的方法,但是它以我需要路由的方式重新路由流量,因此出于我的目的,它可以正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.