Home > Tomcat > mod_jk: Simple and easy

mod_jk: Simple and easy

If you have ever used Tomcat, you’ll know that to access your webapp through the browser, you have to write something like http://www.mydomain.com:8080/myapp. That’s OK in a development environment but it is not very user friendly for commercial application. We can solve this using mod_jk. This Apache module allows us to connect Tomcat with the Apache web server so that we can omit the Tomcat port number (:8080) from the URL.

There are many ways to use and configure mod_jk depending on what you want to achieve. But if you just want to access to your Tomcat applications using a URL like http://mydomain.com/myapp, you don’t need to create workers or config  files. I think this is the easiest way to do it.

First of all, make sure you have mod_jk module installed and Apache loads it correctly. You may have to write this line in your httpd.conf file (usually placed in /etc/httpd/conf/httpd.conf):

LoadModule jk_module modules/mod_jk.so

Then, in your httpd.conf file locate the VirtualHost tag you want to redirect and add this two lines inside:

JkMount /myapp ajp13
JkMount /myapp/* ajp13

If you don’t know which VirtualHost tag is the one you need to change, just look for the one that contains a line like:

ServerAlias "www.mydomain.com"

Save the changes and restart your Tomcat and apache servers.

Now if someone types http://www.mydomain.com/myapp in his browser, the myapp Tomcat application will be loaded.

Note that if you have an SSL certificate for this domain, the app can be access through HTTPS without any extra configuration. Just go to https://www.mydomain.com/myapp and you’ll get it.

Categories: Tomcat Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: