Thursday, February 03, 2011

Hide context URL in Tomcat

Regardless if you use Apache plus modjk or any other way to separate the HTTP server from Tomcat (highly recommended in production environment) you will face the alternative between a nice looking URL like:
http://example.com/login
versus
http://example.com/my-app/login

For this to work you will need to configure the Host node in server.xml as shown below. Notice the full path which is required and makes sense as this is an environment specific setting.
...
      <Host name="bhub.nestorurquiza.com" debug="0">
                <Context path=""
                         docBase="/opt/tomcat/webapps/my-app"/>
      </Host>
    </Engine>
  </Service>
</Server>

No comments:

Followers