How to Redirect Your Tomcat or JBoss Over Port 80 Print

  • 273

How to Redirect Your Tomcat or JBoss Over Port 80

This article is for customers with a dedicated server, VPS or Cloud VPS.

There is more than one way to handle this. Below is one such method that works well on a production based environment for both Apache Tomcat and JBoss.


  • CentOS
  • Apache httpd and httpd-devel installed
  • Tomcat or JBoss installed and running on port 8080.
  • Root or sudo access.

Install Tomcat Connector 1.2 (mod_jk)

# wget
# tar xvzftomcat-connectors-1.2.31-src.tar.gz
# cd tomcat-connectors-1.2.31/native
# ./configure --with-apxs=/usr/sbin/apxs
# make
# su -c 'make install'
# cd ../conf/
# cp httpd_jk.conf /etc/httpd/conf.d/
# cp /etc/httpd/conf/

Edit /etc/httpd/conf/ so that it has the following worker info after the manager entries:

worker.list=worker1 (for first worker)

The port 8009 is the port found in tomcats coyote connector port in tomcat/conf/server.xml. Its also the same port for jboss using ports-default.

Finally you need to edit your virtualhost entry in either httpd.conf or its own file in /etc/httpd/conf.d/ (best practice is to use use separate file for each domain in /etc/httpd/con.d/)

Add the following JkMounts to your virtualhost entry just before the closing VirtualHost tag:

JkAutoAlias /opt/tomcat/webapps
JkMount /* worker1
JkMount /*/* worker1
JkMount /somefolder/* worker1
No need to change any configurations in Tomcat or Jboss.
Restart httpd and then Tomcat or Jboss.
You can also run multiple instances of Tomcat or JBoss servers with the above method.
After the first worker in, create new one:
worker.list=worker2 (for second worker)
worker.worker2.port=8109 (Updated port which must be unique as with 8080/8180)
Then include the following in the VirtualHost entry for new domain:
JkAutoAlias /opt/tomcat2/webapps
JkMount /* worker2
JkMount /*/* worker2
JkMount /somefolder/* worker2
Be sure to change port 8080, 8009, 8005 to 8180, 8109, 8105 in server.xml of tomcat.
For JBoss, just change the ports to ports-01 instead of ports-default in in jboss/server/servername/conf/
JBoss 5 and up now manages those ports in jboss/server/servername/conf/server/servername/conf/bindingservice.beans/META-INF/bindings-jboss-beans.xml
We will be happy to help you with these configurations. Just holler by submitting a support ticket.

If you don't want the hassle of managing your Tomcat environment yourself, start using a Java web host such as JavaPipe today.

Was this answer helpful?

« Back