Tomcat Behind Apache

Posted onby admin

Apache Tomcat and the World Wide Web

  1. Here are just a few reasons to use your Tomcat app server behind Apache: High availability by providing load balancing between multiple Tomcat app servers Static content can be processed.
  2. The Tomcat is listening on port 8090 for HTTP requests here. If the reverse proxy serves the content with HTTPS have a look at the scheme, proxyName and proxyPort attributes in the Connector element as you may have to add those. Before configuring the reverse proxy part make sure that the Apache Webserver has the proxy module enabled.
  3. Apr 26, 2012 While preventing direct web access to the Tomcat server (which is generally considered unsecure), it still makes Tomcat web applications publicly available via requests to the Apache web server. This setup served well for deploying our (mostly eXist -driven) web applications.

Usually when running an application server, such as Apache Tomcat, you bind a connector directly on port 80. This way users visiting your web application will be able to navigate through your server just by calling your domain instead of calling your domain and special port ( If there is no option to bind a Tomcat connector on port 80 (some systems ban this functionality for security purposes), there are other ways to achieve this behavior such as setting a redirect on port 80 to port 8080 (Tomcat’s default, or any other) using IPTables or any other port redirection tool. Both options are really simple procedures, but are a great issue if you need to run a simple HTTP server on your machine too.

Apache Tomcat —or, Tomcat for short — is a popular tool in enterprise infrastructure. And there are many ways in which Tomcat can shine as a Java application container. In this blog, we share. Tomcat behind apacheHelpful? Please support me on Patreon: thanks & praise to God, and with thanks to the many peo.

Apache HTTP and mod_proxy

To solve this problem we can run Apache HTTPD as a front-end proxy for Apache Tomcat and redirect traffic to the application server based on a set of rules. In this tutorial we will use mod_proxy, although there are many other options available.

This tutorial assumes that Apache Tomcat is already installed and configured with the default connector settings (port 8080) and Apache HTTP is installed too with the default listener settings (port 80).

Tomcat behind apache block

For this tutorial we are going to assume that there are 2 different domains ( and pointing to the same IP address. The user expects to reach the application server when navigating to one domain and the web server when navigating to the other.

First step is make sure that the file httpd.conf has mod_proxy enabled (which is by default), so in case it isn’t, uncomment the following line.

LoadModule proxy_module modules/

Taking into account that there are 2 domains, we need to use the NameVirtualHost directive and define two virtual hosts based on the different domains.

NameVirtualHost *:80

Next we define the virtual host that will redirect traffic to tomcat. In case tomcat has some virtual hosts defined too, we’ll add a ServerAlias for each domain that needs to reach tomcat

Tomcat Vs Apache

ServerAdmin root@localhost

Tomcat Behind Apache Loop

With this code, all traffic will be served by Apache HTTP, and only those requests to the ‘/tomcat’ context path will be proxied to Apache Tomcat. So will be served by a Apache HTTP and will be served by Apache Tomcat.