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

美好的一天,

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

我已经将以下条目添加到Apacheconfiguration中:

 <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重写的debugging日志,我看到确实是一个奇怪的事情 – 它看起来像重写发生了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

如何解决它?

谢谢

这很奇怪,因为不应该有任何东西在子请求上附加。

让我们看看是否有任何更改时,通过添加一个NS标志不适用于疯狂的子请求:

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