tomcatapache2tomcat6mod-proxyapache2-module

session attributes no longer working when going through mod_proxy


I have a tomcat app running on "http://localhost:8080/appexploded/login.jsp" (Tomcat). Now I have installed Apache and am running mod_proxy so that all request on port 80 can be proxied to 8080. In my httpd.conf file, here is what I have:

LoadModule proxy_module  /usr/lib/apache2/modules/mod_proxy.so

ProxyPass         /ordergeek  http://localhost:8080/appexploded
ProxyPassReverse  /ordergeek  http://localhost:8080/appexploded 

So when I make a request to the :8080 directly, my request.getSession().getAttribute("BLAH") works from one page to another. However, When I go to "http://localhost/ordergeek/login.jsp", that page sets a session attribute, and then redirects to another page. However, that next page tries to read the request.getSession().getAttribute("BLAH"), and it doesn't find it.

When I don't go through the proxy... the session attributes work. When I go through the proxy, they don't. What am I missing?

I added the following to my server.xml:

<Connector port="8080" 
          proxyName="www.myappurl.com"
          proxyPort="80"/>

Solution

  • It is an old one but as this thread comes up in the first google search results and as I hardly found the answer elsewhere, it might help :

    You just have to add a ProxyPassReverseCookiePath directive in order to get the path corrected in the cookies:

    ProxyPassReverseCookiePath /appexploded /ordergeek  
    

    Once this set, you should get your session attributes as usual.

    Notice that you must use Apache 2.2 or later.