Question

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"/>
Was it helpful?

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.

OTHER TIPS

It's very difficult to change the web-application name when Apache HTTPD is in the path. You have to not only use ProxyPassReverse but also translate all the outgoing HTML to rewrite any links placed there by the application. There is a 3rd party mod_proxy_html module that does that, but you should really reconsider the whole strategy. IMHO rewriting HTML is part of the problem, not part of the solution. Just rename your web app internally at Tomcat.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top