Ever had a requirement of deploying a Tomcat Web Application such that you need to get that under
http://example.com instead of
http://example.com:8080/webapp.
Here is what needs to be done:
1. Run the Tomcat Server in port 80 instead of port 8080:
This can be done under the
server.xml file present under
"tomcat_home/conf". Open the server.xml file and find the part that says:
Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"
Change that to the below form:
Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443"
Once done, the application will be accessible under
http://example.com/webapp
2. Setting a web app to Document Root
There are two easier methods for doing this:
a) The ROOT folder:
By default, the ROOT folder of the Tomcat Server is showing the default Tomcat page. So backup that folder to another suitable location (apart from the "webapps" folder. Now either rename your application folder to the name ROOT (please note that it should be in capitals) or create a soft link for that folder with the name ROOT:
$ mv tomcatapp ROOT
or
$ ln -s tomcatapp ROOT
b) Re-direction method:
Edit the file
tomcat_home/webapps/ROOT/index.html, delete everything (after taking a backup) and place the below content in it:
Change the
http://example.com to your required URL.
Now, your application shall be accessible under http://example.com itself. Easier for the clients to access ;-)
Note: There are other methods also for doing this.