【问题标题】:Apache proxy pass is redirecting instead of acting like a real proxyApache 代理通行证正在重定向,而不是像真正的代理一样
【发布时间】:2021-07-30 11:28:11
【问题描述】:

我正在尝试隐藏已部署容器的端口并使用 ProxyPass 保留原始 url。 我可能错误地配置了一些东西,因为我没有简单地保留原始地址,而是重定向到容器地址(example.com:8014 而不是保留 subdomain.example.com)。 HTTP 响应是:301 Moved Permanently (from service worker)。

这是包含代理的虚拟主机:

<VirtualHost *:80>
        ServerName subdomain.example.com
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =subdomain.example.com
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
        ServerAdmin admin@example.com
        ServerName subdomain.example.com
        ServerAlias subdomain.example.com

        LoadModule proxy_http_module modules/mod_proxy_http.so

        SSLProxyEngine On
        Include /etc/letsencrypt/options-ssl-apache.conf
        SSLCertificateFile /etc/letsencrypt/live/subdomain.example.com/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/subdomain.example.com/privkey.pem

        ProxyPreserveHost On
        ProxyPass / https://example.com:8014/
        ProxyPassReverse / https://example.com:8014/
</VirtualHost>

这是容器内的虚拟主机:

<VirtualHost *:80>
        ServerName example.com
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =example.com:8014
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
        ServerAdmin admin@example.com
        ServerName example.com
        <Directory /var/www/html>
            AllowOverride All
        </Directory>
        SSLEngine On
        SSLProtocol             all -SSLv2 -SSLv3 -TLSv1 -TLSv1.1
        SSLCipherSuite          ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
        SSLHonorCipherOrder     off
        SSLSessionTickets       off
        SSLOptions +StrictRequire
        SSLCertificateFile /etc/apache2/fullchain.pem
        SSLCertificateKeyFile /etc/apache2/privkey.pem
</VirtualHost>

容器端口映射如下:80->8012、443->8014。

我的目标是在不更改地址的情况下使用 subdomain.example.com 访问 example.com:8014。 此外,我什至不确定为什么在使用 example.com:8012 时我没有被重定向到端口 8014 上的 https。 问题一定出在容器虚拟主机上,因为它正在生成 301 状态代码。

【问题讨论】:

  • 显然是谷歌浏览器错误。不知何故,它在使用边缘时缓存了重定向,它工作得很好。擦除 chrome 缓存已修复。这很奇怪,尤其是因为即使在隐身模式下,重定向仍然会被缓存。

标签: apache proxy reverse-proxy


【解决方案1】:

配置工作得很好。 发生这种情况时,我会建议清除 google chrome 的缓存。

【讨论】:

    猜你喜欢
    • 2019-05-23
    • 1970-01-01
    • 2020-01-07
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    • 2012-05-31
    • 2020-11-20
    • 1970-01-01
    相关资源
    最近更新 更多