If you're using mod_proxy to forward requests that use sessions to other servers, you need to ensure that the cookies get correctly rewritten as they're sent to the browser for setting, in order to reflect the URL of the customer facing server rather than the back end server.
Here's an example where we have forwarded all requests to our front facing server for a web application called /henry to a back end server on our internal network at 192.168.200.218, on port 5050, to a web application called /latmjdemo.
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /henry http://192.168.200.218:5050/latmjdemo
ProxyPassReverse /henry http://192.168.200.218:5050/latmjdemo
ProxyPassReverseCookiePath /latmjdemo /henry
The ProxyPassReverse is required in order for redirect URLs (such as the sort you generate if you leave the trailing slash off a directory request), and the ProxyPassReverseCookiePath is required in order to allow the back end server to correctly set cookies in the user's browser.
Here's an example of a test page that we've accessed via an httpd process running on 192.168.200.215, which has called up a session / cookie based application running on Tomcat on 192.168.200.218 - the configuration file above is off 192.168.200.215
The source code for that .jsp page may be found
here. Example written in answer to a training customer's query / during a practical session. See
course details.
(written 2008-12-14, updated 2008-12-15)
Associated topics are indexed under
A608 - Web Application Deployment - Apache httpd mod_proxy [3892] Distributed, Balanced and Clustered Load Sharing - the difference - (2012-10-13)
[3680] How can I run multiple web servers behind a single IP address? - (2012-04-02)
[3339] Simplest ever proxy configuration? - (2011-06-28)
[3293] Distributing the server load - yet ensuring that each user return to the same system (Apache httpd and Tomcat) - (2011-05-18)
[2482] Load balancing with sticky sessions (httpd / Tomcat) - (2009-10-29)
[2325] Apache, Tomcat, mod_proxy - (2009-08-06)
[2273] Three recent questions on Tomcat Convertors - (2009-07-07)
[2062] Virtual hosting and mod_proxy forwarding of different domains (httpd) - (2009-03-01)
[1939] mod_proxy_ajp and mod_proxy_balancer examples - (2008-12-13)
[1767] mod_proxy and mod_proxy_ajp - httpd - (2008-08-22)
[1566] Strange behaviour of web directory requests without a trailing slash - (2008-03-06)
[1376] Choosing between mod_proxy and mod_rewrite - (2007-10-02)
[1121] Sharing the load with Apache httpd and perhaps Tomcat - (2007-03-29)
[1006] Apache httpd and Apache Tomcat together tips - (2006-12-24)
[934] Clustering, load balancing, mod_rewrite and mod_proxy - (2006-11-21)
[631] Apache httpd to Tomcat - jk v proxy - (2006-03-03)
A655 - Web Application Deployment - Using Tomcat and Apache httpd Together [3999] Handling failures / absences of your backend server nicely - (2013-02-08)
[3018] Tuning Apache httpd and Tomcat to work well together - (2010-10-27)
[1940] URL rewriting with front and back servers - (2008-12-14)
[1938] Predictive Load Balancing - PHP and / or Java - (2008-12-13)
[1771] More HowTo diagrams - MySQL, Tomcat and Java - (2008-08-24)
[1552] Extra public classes in deploying Apache httpd and Tomcat - (2008-02-24)
[1549] http, https and ajp - comparison and choice - (2008-02-22)
[1383] Monitoring mod_jk and how it is load balancing - (2007-10-07)
[576] Why run two different web servers - (2006-01-25)
[436] Linking Apache httpd to Apache Tomcat - (2005-09-05)
A657 - Web Application Deployment - Using httpd to front Tomcat [2483] Clustering on Tomcat - (2009-10-30)
[1377] Load Balancing with Apache mod_jk (httpd/Tomcat) - (2007-10-02)
4fc8
Some other Articles
Blame CulturePerl substitute - the e modifierVariable Types in PerlSummary - Apache httpd build on LinuxForwarding session and cookie requests from httpd to TomcatPort and GlassesChristmas scenes and eventsServer - Service - Engine - Host, Tomcat