【问题标题】:port redirection of my nodejs application with apache2使用 apache2 对我的 nodejs 应用程序进行端口重定向
【发布时间】:2020-04-23 15:45:57
【问题描述】:

我的系统由 Amazon LighSail 托管。 我的应用程序在端口 3000 上使用 Nodejs 运行。 我使用 Let's Encrypt 为我的域名安装了 HTTPS 证书。

现在我想直接访问我的 nodejs 应用程序到我的 sub-domain.domain.com。 当我转到我的域名 (sub-domain.domain.com) 时,我会被定向到 bitnami 主页。

所以我有:

https://sub-domain.domain.com --> bitnami 主页

IP-ADDRESS:3000 --> 我的 nodejs 应用程序

我添加了一个代理,将所有 HTTP 请求重定向到我的端口 3000,但没有成功。

我的代理添加到 /etc/apache2/sites-enabled/000-default.conf :

< VirtualHost *:80 >

ServerAdmin webmaster@localhost

ServerName www.sub-domain.domain.com

ProxyPass / http://127.0.0.1:3000/

ProxyPassReverse / http://127.0.0.1:3000/

DocumentRoot /var/www/html

ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined 

< / VirtualHost >

有人有解决我问题的想法或任何线索?

【问题讨论】:

    标签: node.js apache apache2 lets-encrypt


    【解决方案1】:

    使用 SSL 证书,配置应该看起来更像这样:

    <VirtualHost *:80>
    
            ServerName yoursite.com
            ServerAlias *yoursite.com
            ServerAdmin example@yoursite.com
            DocumentRoot /var/www/yourSite
            LogLevel debug
    
            SSLEngine on
            SSLCertificateFile /path/to/lets/encrypt/cert
            SSLCertificateKeyFile /path/to/lets/encrypt/key
    
            SSLProxyEngine on
    
            ProxyPass "/" "http://127.0.0.1:3000/"
            ProxyPassReverse "/" "http://127.0.0.1:3000/"
    
            ErrorLog ${APACHE_LOG_DIR}/yourSite_error_https.log
            CustomLog ${APACHE_LOG_DIR}/yourSite_access_https.log combined
    
    
    </VirtualHost>
    

    【讨论】:

      【解决方案2】:

      解决了!我必须在这个文件中添加我的代理:/opt/bitnami/apache2/conf/bitnami/bitnami.conf

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-01-15
        • 1970-01-01
        • 2018-06-04
        • 2020-02-19
        • 1970-01-01
        • 1970-01-01
        • 2019-07-06
        • 2021-04-24
        相关资源
        最近更新 更多