问题描述
我使用国防部重写来掩盖我的应用程序的上下文根。例如,
重写规则^ /目录/(.*)平衡器:// appcluster /目录/ $ 1 [P]
该appcluster看起来是这样的:
<代理平衡器:// appcluster>
BalancerMember的http://本地主机:8080 /应用程序路径= app_01存活=开loadfactor = 1 TTL = 300分= 3 = S-MAX最大5 = 15ProxySet lbmethod = byrequests stickysession = JSESSIONID | JSESSIONID超时= 120 = nofailover上
< /代理>
我是否需要使用 ProxyPassReverse
呢?我用它,因为我的旧的Web服务器code是这样的:
的ProxyPass /应用平衡器:// appcluster lbmethod = byrequests stickysession = JSESSIONID | JSESSIONID超时= 120 = nofailover上ProxyPassReverse /应用的http://本地主机:9013 /应用
的 ProxyPassReverse
是用来改变的应用程序(appcluster)发送的头到Apache,Apache之前发送它的浏览器。例如,如果应用程序坐镇以及它试图将浏览器重定向,比方说, / NEW_LOCATION /
,那么它将与和Apache将以此并将它发送关闭浏览器。但问题是,浏览器(假设它是在其他地方),然后试图发送到,并得到一个错误。
什么ProxyPassReverse作用是拦截那些头,并重写他们,使他们匹配什么的做代理Apache服务器的模样。所以,如果我的Apache服务器托管,我有一个的ProxyPass
这点 /
来,如果坐在本地主机应用:9013返回重定向到,我会需要使用 ProxyPassReverse
,以便它被改写为通过Apache的发送请求回浏览器。
如果你不发出重定向,这不会是一个问题,但它不伤害有它存在的情况下,会返回一个301/302重定向。尽可能的mod_rewrite的重写规则适用于请求将要在App,而不是响应来自应用程序的到来。因此,他们是互斥事件。
I am using mod rewrite to mask the context root of my application. For example,
RewriteRule ^/directory/(.*) balancer://appcluster/directory/$1 [P]
The appcluster looks like this:
<Proxy balancer://appcluster>
BalancerMember http://localhost:8080/App route=app_01 keepalive=On loadfactor=1 ttl=300 min=3 smax=5 max=15
ProxySet lbmethod=byrequests stickysession=JSESSIONID|jsessionid timeout=120 nofailover=On
</Proxy>
Do I need to use ProxyPassReverse
at all? I used to use it because my old webserver code looked like this:
ProxyPass /App balancer://appcluster lbmethod=byrequests stickysession=JSESSIONID|jsessionid timeout=120 nofailover=On
ProxyPassReverse /App http://localhost:9013/App
The ProxyPassReverse
is used to change the headers sent by the app (appcluster) to Apache, before Apache sends it the browser. For example, if the app sits at http://localhost:9013/, and it tries to redirect the browser to, say, /new_location/
, then it will respond with a redirect and location header of http://localhost:9013/new_location/, and Apache will take this and send it off to the browser. Problem is, the browser (assuming it's somewhere else) then tries to send a request to http://localhost:9013/new_location/, and gets an error.
What ProxyPassReverse does is intercepts those headers, and rewrites them so that they match what the Apache server that's doing the proxying looks like. So if my apache server is hosting http://myhost.com/ and I have a ProxyPass
that points /
to http://localhost:9013/App, if the application sitting at localhost:9013 returns a redirect to http://localhost:9013/App/new_location/, I'll need to use ProxyPassReverse
so that it gets rewritten to http://myhost.com/new_location/ by Apache before sending the request back to the browser.
If you aren't issuing redirects, it's not going to be an issue, but it doesn't hurt to have it there in case a 301/302 redirect is returned. As far as mod_rewrite, the RewriteRule applies to the request going to the App, and not the response coming from the App. So they are mutually exclusive events.
这篇关于我是否需要使用ProxyPassReverse如果我使用国防部重写?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!