【问题标题】:Apache - exposing webapp on port using subdomain / route with SSLApache - 使用带有 SSL 的子域/路由在端口上公开 webapp
【发布时间】:2020-09-17 14:44:40
【问题描述】:

我正在尝试通过带有 SSL 的子域或通过路由公开 Web 应用程序。

子域方法:

我正在运行的 webapp 在端口:http://localhost:4567/

通过以下配置,网络浏览器告诉我应用程序“不安全”(非 https)。

该应用程序通常运行良好,但不是 https。

我做错了什么? 有其他配置吗?

<IfModule mod_ssl.c>
    Listen 443
    NameVirtualHost *:443
</IfModule>

<VirtualHost *:80>
  ServerName blast.example.com
  Redirect permanent / https://blast.example.com/
</VirtualHost>

<IfModule mod_ssl.c>

<VirtualHost *:443>
    ServerAdmin me@gmail.com
    ServerName blast.example.com
    # ProxyPreserveHost On
    ProxyRequests off

    # setup the proxy
    <Proxy *>
        Order allow,deny
        Allow from all
    </Proxy>
#    ProxyPass / http://localhost:4567/
#    ProxyPassReverse / http://localhost:4567/

  <Location />
    ProxyPass http://localhost:4567/
    ProxyPassReverse http://localhost:4567/
  </Location>

  SSLEngine on
  SSLProtocol all -SSLv2 -SSLv3
  SSLCipherSuite ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL

  SSLCertificateFile ...
  SSLCertificateKeyFile ...
  Include /etc/letsencrypt/options-ssl-apache.conf

</VirtualHost>

我一直在遵循How to configure multiple subdomain with SSL in Apache? 给出的处方

路径/路线方法

我还尝试将应用程序公开为路由路径(即https://example.com/blast

  <Location /blast/ >
    ProxyPass http://localhost:4567/
    ProxyPassReverse http://localhost:4567/
  </Location>

但如果我从以下方面开始,反向代理将无法正常工作:

https://example.com/blast

然后单击起始页上的任何内容。 该应用程序会生成一个没有 /blast 部分的内部 URL,从而导致 404:

https://example.com/blah-blah-generated-url 
(should be https://example.com/blast/blah-blah-generated-url)

总的来说,子域路径似乎效果更好,除了非https问题。

【问题讨论】:

    标签: apache2 subdomain http-proxy


    【解决方案1】:

    设置路径/路线:

    使用https://example.com/blast 使应用程序可访问。如果应用产生新的路由,则需要ProxyPassReverse;否则;只需要 ProxyPass。

    <VirtualHost *:443>
      ...
      ProxyPass "/blast/" "http://localhost:4567/"
      ProxyPassReverse "/blast/" "/"
      ...
    

    在示例 1 中找到,此处:ProxyPassReverse doesn't rewrite Location (http header)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-06
      • 1970-01-01
      • 2021-02-25
      • 1970-01-01
      • 1970-01-01
      • 2015-01-17
      • 1970-01-01
      相关资源
      最近更新 更多