I am in a hosting fix! I have developed a web app for my organisation that allows sharing, interacting, etc. I want to DEPLOY IT ON LAN. BUT...

I don't want the end user to type:

Instead I want him to type: http://www.webapp.com and let the local DNS on the intranet resolve it to the corresponding IP.

I can do a little..I succeed in this: "www.webapp.com:8080".

I don't want the 8080 to be typed.

Though I found a way to do this. I am not fully satisfied.

The browser by default sends all the http requests to port 80. So, I used iptables on the server, and redirected the request to port 8080. That didn't seem worthwhile discovery.

SO, I hear about virtual hosting on apache-tomcat, which they say is a solution to this.

Show me light!

closed as unclear what you're asking by Jeff Schaller, Wouter Verhelst, jimmij, slm Jun 30 '16 at 15:12

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • Is there already a site @ www.webapp.com? – frogstarr78 Sep 29 '11 at 1:56
  • @Abhishek so you figured it out? – Nikhil Mulley Jan 15 '12 at 7:25

As far as I understand your question, you are asking for port redirection from apache at port 80 to your tomcat appserver running at 8080 port, at the same time have your apache mask the port in http headers and have users do not have to explicitly type the port number in the browsing url. This needs Application bridging between Apache and your tomcat application server running on the same host. Assuming that you are going to host a apache virtualhost on the host, you need to configure dns to point application CNAME to the host.

You can do this in many ways. One of the methods are in no particular order(but may be in terms of easiness of setup relatively)

  • mod_rewrite & mod_proxy apache module. Easy to setup. Only involves httpd configuration. Just acts as proxy rewrite for http traffic at port 80 destined for the virtual host to tomcat http server. So far, I find this to be pretty neat and simple, from administration point of view. I will let the developer/app-manager responsible for tomcat installation take care of updating the server.xml file.

    Reference: http://tomcat.apache.org/tomcat-5.5-doc/proxy-howto.html Example:

    <VirtualHost *:80>
    ServerName yourapp.yourdomain.com
    ServerAlias yourapp.*        
    ProxyRequests Off
    ProxyPreserveHost On     
    <Proxy *>
    Order deny,allow
    Allow from all
    ProxyPass /webapp http://localhost:8080/webapp
    ProxyPassReverse /webapp http://localhost:8080/webapp    
    <Location /webapp>
      Order allow,deny
      Allow from all
  • Running JSP Through Apache using mod_jk2 module. Medium hard. Involves complex parameter setup in httpd configuration, useful if the same virtual host needs to execute other scripts such as php/perl/cgi other than passing the traffic to Tomcat server. There is an excellent HOWTO in these links.





  • Run JSP through Apache mod_proxy_ajp module: Its similar to the above approach, but this module aligns with using ajp protocol communication with tomcat instead of http for the sake of consistency.



  • Solve this at the network layer of the host. Use iptables to redirect all the incoming traffic at port 80 bind to port 8080 by default. Involves understanding and managing the iptables settings. One time setup, but difficult to maintain. Can get problematic, if you have to host other Apache virtualhosts on the same machine.


iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A OUTPUT -d localhost -p tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A OUTPUT -d $(/bin/hostname) -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A PREROUTING -d $(/bin/hostname) -p tcp --dport 80 -j REDIRECT --to-port 8080

DNS associates a host name with an IP address. It knows nothing about specific ports. If you don't specify a port in the URL, then the browser will contact the IP address returned by DNS, on port 80. Reditecting port 80 to port 8080 with iptables is the right solution.

  • redirecting port 80 to port 8080 with iptables is appropriate unless there are other virtual hosts/static web content/ to be served off the apache server; which can get difficult if all the traffic is redirected to tomcat application server. – Nikhil Mulley Jan 14 '12 at 18:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.