Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mod rewrite httpd2.2使用带有RewriteCond的反向代理进入无限循环_Mod Rewrite_Infinite Loop_Mod Proxy - Fatal编程技术网

Mod rewrite httpd2.2使用带有RewriteCond的反向代理进入无限循环

Mod rewrite httpd2.2使用带有RewriteCond的反向代理进入无限循环,mod-rewrite,infinite-loop,mod-proxy,Mod Rewrite,Infinite Loop,Mod Proxy,我想引导没有特定cookie集(c\u cntry)且请求URL没有国家/地区值作为路径中的第一个元素的传入请求,该请求将尝试找出c\u cntry的正确设置 但是当我发送类似http://localhost:8085/something-待办事项在浏览器中,我的日志中出现了无休止的递归,最终浏览器中出现了502代理错误。日志似乎显示未触及ProxyPass指令中给出的localhost:9999 非常感谢您帮助解决这个问题 httpd.conf RewriteLogLevel 3 Rewri

我想引导没有特定cookie集(
c\u cntry
)且请求URL没有国家/地区值作为路径中的第一个元素的传入请求,该请求将尝试找出
c\u cntry
的正确设置

但是当我发送类似
http://localhost:8085/something-待办事项
在浏览器中,我的日志中出现了无休止的递归,最终浏览器中出现了502代理错误。日志似乎显示未触及ProxyPass指令中给出的
localhost:9999

非常感谢您帮助解决这个问题

httpd.conf

RewriteLogLevel 3

RewriteRule .*\.php$ - [L]

#req doesnot have country nor is a good cookie present -- send it for geo-discovery

RewriteCond %{REQUEST_URI} !^/(usa|india)/
RewriteCond %{HTTTP_COOKIE} !u_cntry=(usa|india)
RewriteRule (.*) /GeoDiscover?orig=($1)  [QSA,P]

ProxyRequests Off
ProxyPreserveHost On
ProxyTimeout 5
ProxyPass /GeoDiscover http://localhost:9999/GeoDiscover connectiontimeout=1 timeout=3 retry=3 
ProxyPassReverse /GeoDiscover http://localhost:9999/GeoDiscover
重写日志:

127.0.0.1 - - [06/Aug/2011:12:07:58 +0530] "GET /ex2.php HTTP/1.1" 200 42 server:some-server-name file:C:/myhtdocs/ex2.php
127.0.0.1 - - [06/Aug/2011:12:08:02 +0530] "GET /something-to-do HTTP/1.1" 502 409 server:some-server-name file:proxy:http://localhost:8085/GeoDiscover?orig=(/something-to-do)
127.0.0.1 - - [06/Aug/2011:12:08:02 +0530] "GET /GeoDiscover?orig=(/something-to-do) HTTP/1.1" 502 401 server:some-server-name file:proxy:http://localhost:8085/GeoDiscover?orig=(/GeoDiscover)&orig=(/something-to-do)
127.0.0.1 - - [06/Aug/2011:12:08:02 +0530] "GET /GeoDiscover?orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/something-to-do) HTTP/1.1" 502 401 server:some-server-name file:proxy:http://localhost:8085/GeoDiscover?orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/something-to-do)
127.0.0.1 - - [06/Aug/2011:12:08:02 +0530] "GET /GeoDiscover?orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/something-to-do) HTTP/1.1" 502 401 server:some-server-name file:proxy:http://localhost:8085/GeoDiscover?orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/something-to-do) ...
访问日志

127.0.0.1 - - [06/Aug/2011:12:07:58 +0530] "GET /ex2.php HTTP/1.1" 200 42 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0.1) Gecko/20100101 Firefox/5.0.1" "-" "-"
127.0.0.1 - - [06/Aug/2011:12:08:02 +0530] "GET /something-to-do HTTP/1.1" 502 409 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0.1) Gecko/20100101 Firefox/5.0.1" "127.0.0.1" "localhost:8085"
127.0.0.1 - - [06/Aug/2011:12:08:02 +0530] "GET /GeoDiscover?orig=(/something-to-do) HTTP/1.1" 502 401 "-" "Mozilla/5.0(Windows NT 6.1; WOW64; rv:5.0.1) Gecko/20100101 Firefox/5.0.1" "127.0.0.1, 127.0.0.1" "localhost:8085, localhost:8085"
127.0.0.1 - - [06/Aug/2011:12:08:02 +0530] "GET /GeoDiscover?orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/something-to-do) HTTP/1.1" 502 401 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0.1) Gecko/20100101 Firefox/5.0.1" "127.0.0.1, 127.0.0.1, 127.0.0.1,
127.0.0.1" "localhost:8085, localhost:8085, localhost:8085, localhost:8085"
127.0.0.1 - - [06/Aug/2011:12:08:02 +0530] "GET /GeoDiscover?orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/GeoDiscover)&orig=(/something-to-do) HTTP/1.1" 502 401 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0.1) Gecko/20100101 Firefox/5.0.1" "127.0.0.1, 127.0.0.1, 127.0.0.1,
127.0.0.1, 127.0.0.1" "localhost:8085, localhost:8085, localhost:8085, localhost:8085, localhost:8085" ...
错误日志

[Sat Aug 06 12:08:02 2011] [debug] mod_proxy_htttp.c(56): proxy: HTTP: canonicalising URL //localhost:8085/GeoDiscover
[Sat Aug 06 12:08:02 2011] [debug] proxy_util.c(1525): [client 127.0.0.1] proxy: *: found reverse proxy worker for http://localhost:8085/GeoDiscover?orig=(/something-to-do)
[Sat Aug 06 12:08:02 2011] [debug] mod_proxy.c(1015): Running scheme http handler (attempt 0)
[Sat Aug 06 12:08:02 2011] [debug] mod_proxy_htttp.c(1973): proxy: HTTP: serving URL http://localhost:8085/GeoDiscover?orig=(/something-to-do)
[Sat Aug 06 12:08:02 2011] [debug] proxy_util.c(2011): proxy: HTTP: has acquired connection for (*)
[Sat Aug 06 12:08:02 2011] [debug] proxy_util.c(2067): proxy: connecting http://localhost:8085/GeoDiscover?orig=(/something-to-do) to localhost:8085
[Sat Aug 06 12:08:02 2011] [debug] proxy_util.c(2193): proxy: connected /GeoDiscover?orig=(/something-to-do) to localhost:8085
[Sat Aug 06 12:08:02 2011] [debug] proxy_util.c(2444): proxy: HTTP: fam 2 socket created to connect to *
[Sat Aug 06 12:08:02 2011] [debug] proxy_util.c(2576): proxy: HTTP: connection complete to 127.0.0.1:8085 (localhost)
[Sat Aug 06 12:08:02 2011] [debug] mod_proxy_http.c(56): proxy: HTTP: canonicalising URL //localhost:8085/GeoDiscover^M [Sat Aug 06 12:08:02 2011] [debug] proxy_util.c(1525): [client 127.0.0.1] proxy: *: found reverse proxy worker for http://localhost:8085/GeoDiscover?orig=(/GeoDiscover)&orig=(/something-to-do)
[Sat Aug 06 12:08:02 2011] [debug] mod_proxy.c(1015): Running scheme http handler (attempt 0
[Sat Aug 06 12:08:02 2011] [debug] mod_proxy_http.c(1973): proxy: HTTP: serving URL http://localhost:8085/GeoDiscover?orig=(/GeoDiscover)&orig=(/something-to-do)

尝试再添加一个重写条件:

RewriteCond %{REQUEST_URI} !^/GeoDiscover
那么您的重写规则应该如下所示:

RewriteCond %{REQUEST_URI} !^/(usa|india)/
RewriteCond %{REQUEST_URI} !^/GeoDiscover
RewriteCond %{HTTTP_COOKIE} !u_cntry=(usa|india)
RewriteRule (.*) /GeoDiscover?orig=($1)  [QSA,P]
p.S. 您提供的重写日志——我不认为它是实际的重写日志(至少我以前没有看到过提到
GET
200
响应代码等的格式)

p.p.S.
在执行重写调试时——最好使用
RewriteLogLevel 9
——它会产生更详细的输出(可能太多,因此无法在工作服务器上使用,但它会准确地告诉正在发生的事情)。

嗨,L.O.,感谢您的帮助
我错误地认为,在应用[L]规则后,它将自动通过代理设置。它并没有做到这一点(非常令人困惑,我仍然需要弄清楚)。因此,我所做的是(I)将[L]改为[N],并(ii)按照您的建议预先设置[P]规则。所以现在看起来是这样的:
#规则0
重写规则(^GeoDiscover)(|/.*)$[QSA,P]
这很好。我相信ProxyPassReverse仍然有效。谢谢Dinesh
PS:日志是真实的!