Apache mod_proxy+mod_rewrite = “请求超出限制...”错误

Apache mod_proxy+mod_rewrite = “请求超出限制...”错误

再会,

我正在使用 Apache 作为在 上运行的 Tornado 应用程序的反向代理http://localhost:8090。我希望 Apache 将通过 HTTPS 到达 /api/v2 的所有内容代理到http://localhost:8090。Apache 还负责身份验证,因此我需要将经过身份验证的用户名转发到我的 Tornado 应用程序。因此使用mod_rewrite

我已将以下条目添加到 Apache 配置中:

<Location "/api/v2">
    ProxyPass http://localhost:8090

    # Next four lines are to set X-Forwarded-User
    RewriteEngine On
    RewriteRule .* - [E=RU:%{LA-U:REMOTE_USER}]
    RequestHeader set X-Forwarded-User %{RU}e

    SSLRequireSSL

    AuthType Basic
    AuthName "My site"
    AuthBasicProvider external
    AuthExternal pwauth
    Require valid-user

    Order deny,allow
    Allow from all
</Location>

这很有效,但我在 Apache 日志中看到以下错误:

Request exceeded the limit of 10 subrequest nesting levels due to probable confguration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

我启用了 mod rewrite 的调试日志,确实看到了一件奇怪的事情——看起来重写在循环中发生了 10 次,将请求堆积到自身上:

172.16.0.150 - admin [29/Jan/2014:19:01:06 +0200] [sm397/sid#7f8452235588][rid#7f840c0093b8/initial] (3) [perdir /api/v2/] applying pattern '.*' to uri 'proxy:http://localhost:8090/'
172.16.0.150 - admin [29/Jan/2014:19:01:06 +0200] [sm397/sid#7f8452235588][rid#7f840c01f638/subreq] (3) [perdir /api/v2/] applying pattern '.*' to uri 'proxy:http://localhost:8090/proxy:http://localhost:8090/'
172.16.0.150 - admin [29/Jan/2014:19:01:06 +0200] [sm397/sid#7f8452235588][rid#7f840c00d6a8/subreq] (3) [perdir /api/v2/] applying pattern '.*' to uri 'proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/'
172.16.0.150 - admin [29/Jan/2014:19:01:06 +0200] [sm397/sid#7f8452235588][rid#7f840c025e08/subreq] (3) [perdir /api/v2/] applying pattern '.*' to uri 'proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/'
172.16.0.150 - admin [29/Jan/2014:19:01:06 +0200] [sm397/sid#7f8452235588][rid#7f840c029e28/subreq] (3) [perdir /api/v2/] applying pattern '.*' to uri 'proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/'
172.16.0.150 - admin [29/Jan/2014:19:01:06 +0200] [sm397/sid#7f8452235588][rid#7f840c02de48/subreq] (3) [perdir /api/v2/] applying pattern '.*' to uri 'proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/proxy:http://localhost:8090/'

完整日志在此:http://pastebin.com/raw.php?i=HqnuFFpQ

如何修复?

谢谢

答案1

这非常奇怪,因为不应该有任何东西导致子请求的附加。

NS通过添加一个标志,让我们看看当该规则不应用于疯狂的子请求时是否会发生任何变化:

RewriteRule .* - [E=RU:%{LA-U:REMOTE_USER},NS]

相关内容