1. My old way using mod_jk in apache and configure virtual host in tomcat Within the JSP file, I make reference to CSS as below


as the home link is placed to


which means this labored fine after i use mod_jk in apache to utilize tomcat using ajp

  1. After I attempt to configure reverse proxy as below

ProxyPass / http://localhost:800/mywebapp

ProxyPassReverse / http://localhost:800/mywebapp

the house page could be retrieved fine however the css request becomes http://mydomain.com/mywebapp/mywebapp/css/style.css therefore the css file cannot be retrieved properly

  1. I believe one way possible would be to always employ relative path like ./style.css or ../style.css a. since header/footer are shared, and also the webpage is within another level with detail page, it's bothersome to make use of relative path because they are in a different level b. still, I believe the house link must be /<%=request.getContextPath()%>/

and so i question what's the best way to set contextroot fine in java web as well as work fine with reverse proxy?

thx a great deal

When I know the application server (Tomcat) is not able to understand a reverse proxy presence. In most cases, it may be approached through a variety of reverse proxies or directly by browsers. A network configuration is generally accustomed to limit this, not HTTP or Java.

So, you have to precisely depend on relative Web addresses to create the application work nicely.

After I suffer from reverse proxy presence (more often than not because of SSO architectures), I embed a "junction" configuration string item (the area of the URL utilized in the proxy to map the applying) and employ it within the only places where I have to build a complete URL.