Main Content
Simplest ever proxy configuration? Archive - Originally posted on "The Horse's Mouth" - 2011-06-28 13:03:20 - Graham Ellis
Scenario ... Apache Http Server fronting an Apache Tomcat server. Http Server has mod_rewrite and mod_proxy installed.
When we first did httpd and Tomcat courses, getting the two to talk to each other involved builds of extra modules and all sorts of configuration. I did my "simplest ever" this morning - it came down to these two directives in a .htaccess file:
RewriteEngine On
RewriteRule (.*) http://192.168.200.102:2080/latmjdemo/ [P,L]
Works a treat to forward a whole webapp. Our Deploying Apache httpd and Tomcat course has moved forward considerably over the years- we not have plenty more time for load balancing, cluseting, monitoring, sticky sessions and the like ... runs five of six times a year as a public course, with more delegates being taught on our other private courses than on the public ones.
So as not to overlook the more complex stuff ;-)
<Proxy balancer://crawl>
BalancerMember ajp://192.168.200.102:2009/latmjdemo route=jvm102
BalancerMember ajp://192.168.200.103:2009/latmjdemo route=jvm103
BalancerMember ajp://192.168.200.104:2009/latmjdemo route=jvm104
</Proxy>
ProxyPass /latmjdemo balancer://crawl stickysession=JSESSIONID|jsessionid
ProxyPassReverse /latmjdemo balancer://crawl
ProxyPassReverseCookieDomain .* 192.168.200.102
ProxyPassReverseCookiePath /latmjdemo /latmjdemo
That's a load balanced, sticky session working example
Some other articles
A690 - Clustering and load balancing Java web application for teaching - now with sessions and clustering / load balancing demonstrations Distributed, Balanced and Clustered Load Sharing - the difference This article Distributing the server load - yet ensuring that each user return to the same system (Apache httpd and Tomcat) Clustering on Tomcat Load balancing with sticky sessions (httpd / Tomcat) Sharing the load between servers - httpd and Tomcat Automated server heartbeat and health check Load Balancing - Hardware or Software? More HowTo diagrams - MySQL, Tomcat and Java Sharing the load with Apache httpd and perhaps Tomcat Clustering, load balancing, mod_rewrite and mod_proxy A608 - Apache httpd mod_proxy Distributed, Balanced and Clustered Load Sharing - the difference How can I run multiple web servers behind a single IP address? This article Distributing the server load - yet ensuring that each user return to the same system (Apache httpd and Tomcat) Load balancing with sticky sessions (httpd / Tomcat) Apache, Tomcat, mod_proxy Three recent questions on Tomcat Convertors Virtual hosting and mod_proxy forwarding of different domains (httpd) Forwarding session and cookie requests from httpd to Tomcat mod_proxy_ajp and mod_proxy_balancer examples mod_proxy and mod_proxy_ajp - httpd Strange behaviour of web directory requests without a trailing slash Choosing between mod_proxy and mod_rewrite Sharing the load with Apache httpd and perhaps Tomcat Apache httpd and Apache Tomcat together tips Clustering, load balancing, mod_rewrite and mod_proxy Apache httpd to Tomcat - jk v proxy A607 - Apache httpd mod_rewrite Forwarding a whole domain, except for a few directories - Apache http server Adding a passcode to a directory Telling which ServerAlias your visitor used - useful during merging domains This article Finding and diverting image requests from rogue domains How to set up short and meaningfull alternative URLs Redirecting a page - silent, temporary or permanent? Dynamically watching your web site via a PHP wrapper Carrying a long URL around - looking for memorable shorts Redirecting a home page using mod_rewrite Bookkeeping If you have a spelling mistake in your URL / page name mod_rewrite for newcomers Pointing all the web pages in a directory at a database More HowTo diagrams - MySQL, Tomcat and Java Apache httpd, MySQL, PHP - installation procedure What to do if the Home Page is missing Using a MySQL database to control mod_rewrite via PHP Choosing between mod_proxy and mod_rewrite Simple but effective use of mod_rewrite (Apache httpd) Passing GET parameters through Apache mod_rewrite Apache httpd and Apache Tomcat together tips Clustering, load balancing, mod_rewrite and mod_proxy Using different URLs to navigate around a single script Apache httpd to Tomcat - jk v proxy