12

I'm having some issues with getting cookies to work when using a ProxyPass to redirect traffic on port 80 to a web-application hosted via Tomcat.

My motivation for enabling cookies is to get rid of the "jsessionid=" parameter that is appended to the URLs.

I've enabled cookies in my context.xml in META-INF/ for my web application.
When I access the webapplication via http://url:8080/webapp it works as expected, the jsessionid parameter is not visible in the URL, instead it's stored in a cookie.

When accessing my website via an apache2 virtualhost the cookies doesn't seem to work because now "jsessionid" is being appended to the URLs. How can I solve this issue?

Here's my VHost configuration:

<VirtualHost *:80>
        ServerName somedomain.no
        ServerAlias www.somedomain.no

        <Proxy *>
                Order deny,allow
                Allow from all
        </Proxy>

        ProxyPreserveHost Off
        ProxyPass / http://localhost:8080/webapp/
        ProxyPassReverse / http://localhost:8080/webapp/

        ErrorLog /var/log/apache2/somedomain.no.error.log
        CustomLog /var/log/apache2/somedomain.no.access.log combined
</VirtualHost>

EDIT: The cookie is actually being set. I am guessing that the problem is that the cookie contains the "Path: /webapp".

John
  • 2,571
  • 6
  • 32
  • 40

2 Answers2

22

I figured it out.

Add this to the VHost configuration:

ProxyPassReverseCookiePath /webapp /
John
  • 2,571
  • 6
  • 32
  • 40
0

Thanks for the answer, my complete working configuration looks like this:

<VirtualHost *:80>
    ServerName extener_url.xxx.co.zm
    ProxyRequests Off
    ProxyPass / http://localhost:8080/app/
    ProxyPassReverse / http://localhost:8080/app/
    ProxyPassReverseCookiePath /app /

    ServerAdmin webmaster@localhost
    <Proxy *>
            Order deny,allow
            Allow from all  
    </Proxy>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
</VirtualHost>
Teddy
  • 133
  • 2
  • 5