-1

I have a tomcat7 server hosting my app. I've got port forwarding set up with iptables so right now you can access the app like so:

http://ip-address-of-server/appname

I've also set up the domain routing so you can also access the app at:

http://appname.com/appname

Now I'm stuck because I don't know how to map http://appname.com to http://appname.com/appname.

All I could find is that I need a second web server (Apache) to forward (proxy? rewrite? I'm unclear on the proper terminology) the requests to tomcat, as per this article.

Having two web servers running doesn't seem right, but I can't find any other way of achieving this. I suppose my question is: Is this right? Having two web servers running for one app? Is there a better way?

Thanks for your time!

Liam
  • 101
  • 4

1 Answers1

1

In my experience, you should run 'a second web server' i.e. NGINX or Apache's HTTPD and use that as a proxy for Tomcat. There are many resources to help you configure it this way, and there are many arguments to show why you want to 'front' your tomcat servlet with a http proxy. It mostly boils down to:

  1. Dedicated HTTP servers (NGINX, Apache's HTTPD) are designed to serve lots of clients efficiently
  2. Tomcat is designed to run java servlets (applications)
  3. The dedicated HTTPD servers can terminate SSL easier than having Tomcat do this.

There are some good efficiencies you can achieve by using both across your application.

Things like this however depend a lot on the characteristics of your web application.

  1. How many clients are you planning to serve?
  2. Are there heavy bursts of traffic?
  3. Is it something used internally in a company or for anyone on the internet?

Also see:

http://javadeveloper.asia/configuring-nginx-in-front-of-tomcat-or-other-java-application-server/

http://blog.rezajp.info/posts/configuring-nginx-for-apache-tomcat-7/

I always use this configuration for my applications, especially if you want to run multiple instances of tomcat (and so multiple instances of the JVM) behind the HTTPD proxy.

Andy D
  • 206
  • 2
  • 3