Apache 具有代理身份验证的反向代理

发布于 2024-12-05 21:57:16 字数 1980 浏览 1 评论 0原文

我有以下设置

Box A (192.168.8.180 - 运行 apache 反向代理)

Box B (192.168.8.100:808 - 连接到互联网的代理服务器)

由于内部原因,Box A 的 IP 被重定向到 http://xyz.mydomain.com/。反向代理使用 Box B 中运行的代理来连接到互联网。

当代理不需要任何身份验证时,该设置工作正常。但是当 Box B 的代理需要身份验证时,我对反向代理的所有请求都会失败,并出现以下错误。

<h1>Unauthorized ...</h1>
<h2>IP Address: 192.168.8.180:1799<br>
MAC Address: <br>
Server Time: 2011-09-21 20:32:16<br>
Auth Result: </h2>

这是我的 apache 配置

<VirtualHost *:80>
    ServerName xyz.mydomain.com
    ProxyRequests Off
    ProxyPreserveHost Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyRemote * http://192.168.8.100:808/
    ProxyPass / http://xyz.mydomain.com/
    ProxyPassReverse / http://xyz.mydomain.com/
    RequestHeader set Authorization "Basic cGFuZGlhbjpwYW5kaWFu"


    <Location />
        Order allow,deny
        Allow from all
    </Location>

    ErrorLog "logs/myerror.log"
    CustomLog "logs/myaccess.log" common

</VirtualHost>

有什么想法吗?

访问日志显示以下

127.0.0.1 - - [21/Sep/2011:20:24:55 +0530] "GET / HTTP/1.1" 407 142
127.0.0.1 - - [21/Sep/2011:20:24:57 +0530] "GET / HTTP/1.1" 407 142
192.168.8.180 - - [21/Sep/2011:20:25:33 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:32:07 +0530] "GET / HTTP/1.1" 407 142
192.168.8.180 - - [21/Sep/2011:20:32:14 +0530] "GET / HTTP/1.1" 407 142
192.168.8.180 - - [21/Sep/2011:20:32:15 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:33:58 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:35:03 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:35:16 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:35:24 +0530] "GET / HTTP/1.1" 407 142

内容代理凭据正确。用浏览器验证。

谢谢

I have the following setup

Box A (192.168.8.180 - running apache reverse proxy)

Box B (192.168.8.100:808 - Proxy server to connect to internet)

Due to internal reasons, The IP of box A is redirected to http://xyz.mydomain.com/. The reverse proxy uses the proxy running in Box B to connect to internet.

The setup works fine when the proxy does not need any authentication. But When the proxy at Box B needs authentication, all my request to the reverse proxy fails with the following error.

<h1>Unauthorized ...</h1>
<h2>IP Address: 192.168.8.180:1799<br>
MAC Address: <br>
Server Time: 2011-09-21 20:32:16<br>
Auth Result: </h2>

Here is my apache configuration

<VirtualHost *:80>
    ServerName xyz.mydomain.com
    ProxyRequests Off
    ProxyPreserveHost Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyRemote * http://192.168.8.100:808/
    ProxyPass / http://xyz.mydomain.com/
    ProxyPassReverse / http://xyz.mydomain.com/
    RequestHeader set Authorization "Basic cGFuZGlhbjpwYW5kaWFu"


    <Location />
        Order allow,deny
        Allow from all
    </Location>

    ErrorLog "logs/myerror.log"
    CustomLog "logs/myaccess.log" common

</VirtualHost>

Any ideas?

access log says the following

127.0.0.1 - - [21/Sep/2011:20:24:55 +0530] "GET / HTTP/1.1" 407 142
127.0.0.1 - - [21/Sep/2011:20:24:57 +0530] "GET / HTTP/1.1" 407 142
192.168.8.180 - - [21/Sep/2011:20:25:33 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:32:07 +0530] "GET / HTTP/1.1" 407 142
192.168.8.180 - - [21/Sep/2011:20:32:14 +0530] "GET / HTTP/1.1" 407 142
192.168.8.180 - - [21/Sep/2011:20:32:15 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:33:58 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:35:03 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:35:16 +0530] "GET / HTTP/1.1" 407 142
192.168.8.227 - - [21/Sep/2011:20:35:24 +0530] "GET / HTTP/1.1" 407 142

The proxy credentials are correct. verified with browser.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文