【问题标题】:Stop apache from forwarding Basic Auth headers to reverse proxied tomcat site阻止 apache 将 Basic Auth 标头转发到反向代理的 tomcat 站点
【发布时间】:2015-10-15 01:48:45
【问题描述】:

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

我曾考虑过使用

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>

【问题讨论】:

    标签: linux apache http configuration proxy


    【解决方案1】:

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

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

    【讨论】:

    • 我有同样的问题,RequestHeader unset Authorization 确实解决了这个问题,但是有些 REST 请求端点确实需要 auth 标头。因此,如果不将 vhost conf 文件中的这些路径硬编码为异常,我该如何使其工作?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    • 2015-08-07
    • 1970-01-01
    相关资源
    最近更新 更多