Tomcat Reverse Proxy Session Variable Issue

Posted May 14, 2020 895 views

I am having a problem with setting up a reverse proxy to my Tomcat installation. The website itself is fully working if accessed directly via Tomcat on port 8080. The proxy I have set up broadly works but a few features are not working. For example:

  • session variables are not being passed
  • some js is not working

It looks like the common theme is the session variables. All of these functions work when loading the site directly via Tomcat, so the website itself is not at fault.

I have modified the Apache SSL config file located in sites-available as follows:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

ProxyPreserveHost On
ProxyPass "/"  "http://localhost:8080/MyWebApp/"
ProxyPassReverse "/"  "http://localhost:8080/MyWebApp/"



These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

I have found the answer to this, it needs the following for the jsessionid to work:

ProxyPassReverseCookiePath “/” “http://localhost:8080/MyWebApp/
ProxyPassReverseCookieDomain “/” “http://localhost:8080/MyWebApp/