17.8. Apache mod_proxy

download PDF

17.8.1. About the Apache mod_proxy HTTP Connector

Apache provides two different proxying and load balancing modules for its httpd: mod_proxy and mod_jk. To learn more about mod_jk, refer to Section 17.7.1, “About the Apache mod_jk HTTP Connector”. JBoss EAP 6 supports use of either of these, although mod_cluster, the JBoss HTTP connector, more closely couples JBoss EAP 6 and the external httpd, and is the recommended HTTP connector. Refer to Section 17.2.3, “Overview of HTTP Connectors” for an overview of all supported HTTP connectors, including advantages and disadvantages.
Unlike mod_jk, mod_proxy supports connections over HTTP and HTTPS protocols. Each of them also support the AJP protocol.
mod_proxy can be configured in standalone or load-balanced configurations, and it supports the notion of sticky sessions.
The mod_proxy module requires JBoss EAP 6 to have the HTTP, HTTPS or AJP web connector configured. This is part of the Web subsystem. Refer to Section 15.1, “Configure the Web Subsystem” for information on configuring the Web subsystem.


mod_cluster is a more advanced load balancer than mod_proxy. mod_cluster provides all of the functionality of mod_proxy and additional features. For more information about mod_cluster, see Section 17.6.1, “About the mod_cluster HTTP Connector”.

17.8.2. Install the mod_proxy HTTP Connector into Apache HTTP Server


mod_proxy is a load-balancing module provided by Apache. This task presents a basic configuration. For more advanced configuration, or additional details, see Apache's mod_proxy documentation at For more details about mod_proxy from the perspective of JBoss EAP 6, see Section 17.8.1, “About the Apache mod_proxy HTTP Connector” and Section 17.2.3, “Overview of HTTP Connectors”.


  • Apache HTTP server either from JBoss Enterprise Web Server or provided by operating system needs to be installed. A standalone Apache HTTP server is provided as a separate download in the Red Hat Customer Portal, in the JBoss EAP 6 download area. See Section 17.4.3, “Install Apache HTTP Server in Red Hat Enterprise Linux 5, 6, and 7 (Zip)” for information about this Apache HTTP server if you wish to use it.
  • The mod_proxy modules need to be installed. Apache HTTP server typically comes with the mod_proxy modules already included. This is the case on Red Hat Enterprise Linux and the Apache HTTP Server that comes with the JBoss Enterprise Web Server.
  • You need root or administrator privileges to modify the Apache HTTP Server configuration.
  • In our example we assume that JBoss EAP 6 is configured with the HTTP or HTTPS web connector. This is part of the Web subsystem configuration. Refer to Section 15.1, “Configure the Web Subsystem” for information about configuring the Web subsystem.
  1. Enable the mod_proxy modules in the httpd

    Look for the following lines in your HTTPD_CONF/httpd.conf file. If they are not present, add them to the bottom. If they are present but the lines begin with a comment (#) character, remove the character. Save the file afterward. Usually, the modules are already present and enabled.
    LoadModule proxy_module modules/
    LoadModule proxy_balancer_module modules/
    LoadModule proxy_http_module modules/
    # Uncomment these to proxy FTP or HTTPS
    #LoadModule proxy_ftp_module modules/
    #LoadModule proxy_connect_module modules/
  2. Add a non-load-balancing proxy.

    Add the following configuration to your HTTPD_CONF/httpd.conf file, directly beneath any other <VirtualHost> directives you may have. Replace the values with ones appropriate to your setup.
    This example uses a virtual host. See the next step to use the default httpd configuration.
    <VirtualHost *:80>
    # Your domain name
    ServerName Domain_NAME_HERE
    ProxyPreserveHost On
    # The IP and port of JBoss EAP 6
    # These represent the default values, if your httpd is on the same host
    # as your JBoss EAP 6 managed domain or server
    ProxyPass / http://localhost:8080/
    ProxyPassReverse / http://localhost:8080/
    # The location of the HTML files, and access control information
    DocumentRoot /var/www
    <Directory /var/www>
    Options -Indexes
    Order allow,deny
    Allow from all
    After making your changes, save the file.
  3. Add a load-balancing proxy.

    To use mod_proxy as a load balancer, and send work to multiple JBoss EAP 6 instances, add the following configuration to your HTTPD_CONF/httpd.conf file. The example IP addresses are fictional. Replace them with the appropriate values for your environment.
    <Proxy balancer://mycluster>
    Order deny,allow
    Allow from all
    # Add each JBoss Enterprise Application Server by IP address and port.
    # If the route values are unique like this, one node will not fail over to the other.
    BalancerMember route=node1
    BalancerMember route=node2
    <VirtualHost *:80>
     # Your domain name
     ServerName YOUR_DOMAIN_NAME
     ProxyPreserveHost On
     ProxyPass / balancer://mycluster/
     # The location of the HTML files, and access control information DocumentRoot /var/www
     <Directory /var/www>
      Options -Indexes
      Order allow,deny
      Allow from all
    The examples above all communicate using the HTTP protocol. You can use AJP or HTTPS protocols instead, if you load the appropriate mod_proxy modules. Refer to Apache's mod_proxy documentation for more details.
  4. Enable sticky sessions.

    Sticky sessions mean that if a client request originally goes to a specific JBoss EAP 6 worker, all future requests will be sent to the same worker, unless it becomes unavailable. This is almost always the correct behavior.
    To enable sticky sessions for mod_proxy, add the stickysession parameter to the ProxyPass statement. This example also shows some other parameters which you can use. See Apache's mod_proxy documentation at for more information on them.
    ProxyPass /MyApp balancer://mycluster stickysession=JSESSIONID lbmethod=bytraffic nofailover=Off
  5. Restart the Web Server.

    Restart the web server for your changes to take effect.

Your Apache HTTP server is configured to use mod_proxy to send client requests to JBoss EAP 6 instances, either in a standard or load-balancing configuration. To configure JBoss EAP 6 to respond to these requests, see Section 17.4.8, “Configure JBoss EAP 6 to Accept Requests From External Web Servers”.

Red Hat logoGithubRedditYoutubeTwitter


Try, buy, & sell


About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.