我想引导不是特定cookie集(c_cntry
)的传入请求,并且请求URL没有国家/地区值作为内部服务路径中的第一个元素,该内部服务将尝试找出正确设置c_cntry
。
但是当我在浏览器中发送类似http://localhost:8085/something-to-do
的内容时,我会在日志中收到无限递归,并在浏览器中出现最终的502 Proxy Error。日志似乎表明没有触及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
REWRITE LOG:
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)
答案 0 :(得分:0)
尝试再添加一个重写条件:
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
- 它会产生更详细的输出(可能太多,因此无法在工作服务器上使用,但它会准确地说明发生了什么)。