阻止apache转发Basic Auth标头以反转代理的tomcat站点

时间:2015-07-24 11:41:54

标签: linux apache http configuration proxy

如何阻止Apache 2.4转发Basic Auth标头以反转代理的tomcat站点。目标应用程序尝试使用标头将用户登录到破坏应用程序的应用程序。

我考虑过使用

RequestHeader unset Authorization

但这只是完全禁用Basic Auth

这是vhost:

<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>

1 个答案:

答案 0 :(得分:2)

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

如果您的后端需要 auth标头,那是另一回事,但如果没有,那么这是正确的(并经过全面测试)方法。