It may be necessary to use the HTTP server as a front-end for Tomcat. For example, you may want to keep more than one application server on the same host, and/or you want to access these app servers with the separate DNS names, without adding a port to the URL.

There are two methods that allow you to "glue" Apache HTTP Daemon and Tomcat application server:

With the glue method, it is necessary to configure the Apache HTTP daemon to work as the reverse proxy, which will redirect the client's requests to the app server's HTTP connector.

For this connection type, you need to include the mod_proxy module in the HTTP daemon configuration file. This can be found in the httpd.conf file, which is usually located at /etc/httpd/conf/. However, depending on your OS, this path may vary. You will then need to add some directives to your virtual host configuration.

Details:

In the above example, the HTTP daemon will work in the reverse proxy mode (ProxyRequests Off) and will redirect all requests to the tcp port 8080 on the localhost. So, the configuration of a virtual host looks like the following:

For more detail on mod_proxy, refer to this documentation.

As described above, the 'glue' method can be implemented via one of the following ways:

With the first method, you only need the HTTP daemon and application server, but settings are limited.

With the second method, you can obtain more settings, but you will need to download and install additional modules for the HTTP Daemon that are not included in the default package.

1. Download AJP connector module here.

2. Move the downloaded mod_jk.so file to the HTTPD's module directory, for example /etc/httpd/modules. The directory may be different, depending on the OS.

3. Create the configuration file for the mod_jk.conf module.

LoadModule    jk_module  modules/mod_jk.so
<IfModule jk_module>
  # ---- Where to find workers.properties
        JkWorkersFile   conf.d/workers.properties
  # ---- Where to put jk logs
  JkLogFile       logs/mod_jk.log
  # ---- Set the jk log level [debug/error/info]
  JkLogLevel    info
  # ---- Select the timestamp log format
  JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
  JkRequestLogFormat "%w %R %T"
  # ---- Send everything for context /examples to worker named worker1 (ajp13)
  JkMountFileReload       "0"
</IfModule>

For more details, see the Tomcat documentation.

4. Place the mod_jk.conf file into the directory where other configuration files for Apache HTTP daemon are located. For example, /etc/httpd/conf.d/.

5. Create the workers.properties file, which defines the AJP workers for the HTTP daemon.

worker.list=status, WORKER_NAME
# Main status worker
worker.stat.type=status
worker.stat.read_only=true
worker.stat.user=admin
# Your AJP worker configuration
worker.WORKER_NAME.type=ajp13
worker.WORKER_NAME.host=localhost
worker.WORKER_NAME.port=8109
worker.WORKER_NAME.socket_timeout=120
worker.WORKER_NAME.socket_keepalive=true

Note

In the example above, you can change WORKER_NAME to any value.

6. Put this file in the same directory as the mod_jk.conf file.

7. Update the virtual host configuration.

<VirtualHost *:80>
  ServerName      Enter your server DNS name here
  RedirectMatch	permanent "^/?$" "/portal/"
  ProxyRequests   Off
  JkMount         /*	WORKER_NAME
</VirtualHost>