How to tie domain name with application running on tomcat?

April 29, 2016 560 views
DigitalOcean Apache Deployment Networking Ubuntu


I have installed both apache2 and tomcat7 on my ubuntu14.04 droplet. Apache is running on default port 80 and tomcat7 on 8080. I have an application deployed on tomcat and to access it, the url looks like:

But i want my application to come up when user just enters

How to configure this?

1 Answer

As you are already running Apache, the easiest way to do this would be to set it up as a reverse proxy in front of Tomcat.

First, make sure mod_proxy is enabled by running:

  • sudo a2enmod proxy
  • sudo a2enmod proxy_http
  • service apache2 restart

Then create a new virtual host in a file named /etc/apache2/sites-available/tomcat.conf In it, you can configure it to point your domain to your Tomcat app:

<VirtualHost *:80>

    ProxyRequests On
    ProxyPass / http://localhost:8080/Application_name/
    ProxyPassReverse / http://localhost:8080/Application_name/

Note that the ServerName directive is important. Make sure that the virtual host for what Apache is already serving on port 80 also has ServerName set so that Apache can route the requests correctly.

Finally, enable the site and reload Apache:

  • sudo a2ensite tomcat
  • sudo service apache2 reload

Now visiting should display the Tomcat application.

by O.S. Tezer
In this DigitalOcean article, we are going to see set up Apache on Ubuntu 13 and use it as a reverse-proxy to welcome incoming connections and redirect them to application server(s) running on the same network. For this purpose, we are going to use and work with the mod_proxy extension and several other related Apache modules.
  • Hi Andrew,

    It works. Thanks for helping me out.
    But i got a small issue. My application is loading when user hits the url '' but when i try to do '', it loads the default index page of apache webserver. How can i redirect request to to my application?

    Should i add another entry for it in the tomcat.conf?


Have another answer? Share your knowledge.