阻止 Apache 将 Basic Auth headers 转发到反向代理 tomcat 站点

Stop apache from forwarding Basic Auth headers to reverse proxied tomcat site

如何阻止 Apache 2.4 将基本身份验证 headers 转发到反向代理 tomcat 站点。目标应用程序尝试使用 headers 将用户登录到破坏应用程序的应用程序。

我考虑过使用

RequestHeader unset Authorization

但这只会完全禁用基本身份验证

这是虚拟主机:

<VirtualHost *:80>
    ServerName app.company.tld
    ErrorLog "/var/log/company-proxy/app_prox_error_log"
    CustomLog "/var/log/company-proxy/app_prox_access_log" common
    SSLProxyEngine On
    ProxyRequests Off
    <Proxy *>
            Order deny,allow
            Deny from all
            Allow from all
    </Proxy>
    <Location />
            AuthType Basic
            AuthName "Proxy Auth"
            AuthUserFile /var/www/company-auth/APP/.htpasswd
            Require user username
            Satisfy any
            Deny from all
            Allow from 1.0.0.0/16
    </Location>
    ProxyPreserveHost On
    ProxyPass / http://app.company.tld:1000/
    ProxyPassReverse / http://app.company.tld:1000/
</VirtualHost>

你的初步想法是正确的,RequestHeader unset Authorization是正确的做法。这将 不会 禁用前端的基本身份验证,因为未设置机制运行晚于身份验证检查,但它会阻止 Authorization header 到达后端。

如果你的后端需要 auth headers,那是另一回事,但如果不需要,那么这是正确的(经过彻底测试的)方法做吧。