Report this

What is the reason for this report?

Tomcat Reverse Proxy Session Variable Issue

Posted on May 14, 2020

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
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /var/www/example.com
    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/"

</VirtualHost>
</IfModule>

Thanks



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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/

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.