我们的服务器已经从Apache 2.2.32-> 2.4.20进行了升级,随着这一变化,我的mod_rewrites不再传递给Tomcat端点。
这是Tomcat负载均衡器配置:
<Location /balancer-manager>
SetHandler balancer-manager
</Location>
<Proxy balancer://tomcatHttpCluster>
BalancerMember http://localhost:9946 loadfactor=100
</Proxy>
重写的重写规则:
RewriteCond %{REQUEST_METHOD} POST [NC]
RewriteRule ^/catalog/preferences$ /ac/rest/preferences [B,PT,L,QSA]
还有适用于所有/ ac请求的Location配置:
<Location /ac/>
ProxyPass balancer://tomcatHttpCluster/ac/ stickysession=JSESSIONID
...
</Location>
如果我直接转到/ ac Tomcat端点,它可以工作。 Apache日志:
mod_rewrite.c(477): [client 10.20.3.63:50485] 10.20.3.63 - - [tesla/sid#caa5f8] [rid#f75c230/initial] pass through /ac/rest/preferences
mod_proxy_balancer.c(73): [client 10.20.3.63:50485] canonicalising URL //tomcatHttpCluster/ac/rest/preferences
mod_lbmethod_byrequests.c(95): AH01207: proxy: Entering byrequests for BALANCER (balancer://tomcathttpcluster)
mod_lbmethod_byrequests.c(142): AH01208: proxy: byrequests selected worker "http://localhost:9946" : busy 0 : lbstatus 0
mod_proxy_balancer.c(614): [client 10.20.3.63:50485] AH01172: balancer://tomcathttpcluster: worker (http://localhost:9946) rewritten to http://localhost:9946/ac/rest/preferences
proxy_util.c(1783): AH00924: worker http://localhost:9946 shared already initialized
proxy_util.c(1825): AH00926: worker http://localhost:9946 local already initialized
mod_proxy.c(1159): [client 10.20.3.63:50485] AH01143: Running scheme balancer handler (attempt 0)
mod_proxy_ajp.c(738): [client 10.20.3.63:50485] AH00894: declining URL http://localhost:9946/ac/rest/preferences
mod_proxy_http.c(1903): [client 10.20.3.63:50485] HTTP: serving URL http://localhost:9946/ac/rest/preferences
proxy_util.c(2158): AH00942: HTTP: has acquired connection for (localhost)
proxy_util.c(2212): [client 10.20.3.63:50485] AH00944: connecting http://localhost:9946/ac/rest/preferences to localhost:9946
proxy_util.c(2421): [client 10.20.3.63:50485] AH00947: connected /ac/rest/preferences to localhost:9946
mod_proxy_http.c(1374): [client 10.20.3.63:50485] Status from backend: 200
mod_proxy_http.c(1048): [client 10.20.3.63:50485] Headers received from backend:
mod_proxy_http.c(1051): [client 10.20.3.63:50485] Server: Apache-Coyote/1.1
mod_proxy_http.c(1051): [client 10.20.3.63:50485] Content-Type: application/json
mod_proxy_http.c(1051): [client 10.20.3.63:50485] Content-Length: 218
mod_proxy_http.c(1051): [client 10.20.3.63:50485] Date: Fri, 28 Oct 2016 00:32:26 GMT
mod_proxy_http.c(1646): [client 10.20.3.63:50485] start body send
proxy_util.c(2173): AH00943: http: has released connection for (localhost)
mod_proxy_http.c(1791): [client 10.20.3.63:50485] end body send
mod_proxy_balancer.c(669): [client 10.20.3.63:50485] AH01176: proxy_balancer_post_request for (balancer://tomcathttpcluster)
BUT。如果我尝试使用重写URL - 重写发生......那么没有:
mod_rewrite.c(477): [client 10.20.3.63:50457] 10.20.3.63 - - tesla/sid#c6a5f8rid#dc2a110/initial RewriteCond: input='GET' pattern='GET' [NC] => matched
mod_rewrite.c(477): [client 10.20.3.63:50457] 10.20.3.63 - - tesla/sid#c6a5f8rid#dc2a110/initial rewrite '/catalog/preferences' -> '/ac/rest/preferences'
mod_rewrite.c(477): [client 10.20.3.63:50457] 10.20.3.63 - - tesla/sid#c6a5f8rid#dc2a110/initial forcing '/ac/rest/preferences' to get passed through to next API URI-to-filename handler
我不是Apache的专家(直到现在!),但我确实尝试将mod_rewrite标志更改为[R]并且运行正常。我无法在服务器上进行更改,因为该代码不在我的控制之下。我假设[PT]重写标志会通过mod_proxy_balancer发回重写的url,但这似乎并没有发生。
有什么明显的东西从2.2变为2.4会导致这种情况吗?救命!我已经被困在这几天了。