Choosing between mod_proxy and mod_rewrite
If you're connecting an Apache httpd server to an Apache Tomcat server, you can do so via proxied http requests - i.e. have your customer facing http server relay the request on, perhaps having modified it, to Tomcat and then passing the response back. Two different Apache modules give you the facility - mod_proxy and mod_rewrite.With mod_proxy, You specify the start of the URL and how it is to be replaced in the proxy request, and it forwards on that basis:
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /jd http://192.168.200.1:8882/latmjdemo
ProxyPassReverse /jd http://192.168.200.1:8882/latmjdemo
With mod_rewrite, you use a regular expression instead, and you must use a [P] modifier to trigger the request to be proxied onward rather that written forward within the same server, for example:
RewriteEngine On
RewriteRule je/(.*) http://192.168.200.1:8882/latmjdemo/$1 [P,L]
Which is best? mod_proxy is simpler, and you can (in Apache http2 2.2) also use mod_proxy_balancer to share the forwarding to different proxy servers. mod_rewrite has more flexibility and can be used if you want to share servers, but forward all visits that form part of the same session to the same server in the pool to provide you with practical load balancing.
We cover this subject briefly on our Deploying Apache httpd and Tomcat course and can cover it in more depth on private courses. (The sample configurations above happen to come from a private course I was giving today!)
Read full article from Choosing between mod_proxy and mod_rewrite
No comments:
Post a Comment