Home Guides Glossary

How to Set up a Reverse Proxy

A proxy is an application that processes resource requests between client computers and servers. A reverse proxy retrieves those resources from the servers on behalf of the clients, just as if the resources came directly from the servers.

Reverse proxies have a variety of specific applications, especially for web servers. A single computer may need to run multiple web servers where each server listens to incoming service requests on a different port. A reverse proxy can then analyze each request and deliver it to the appropriate server. For example, a CentOS computer running Apache and Tomcat servers can use a reverse proxy to allow Tomcat to request resources from Apache.

DIFFICULTY Basic - 1 | Medium - 2 | Advanced - 3
TIME REQUIRED 15 min
RELATED PRODUCTS Linux-based VPS or dedicated servers
  • Here is a quick tutorial on how to setup a reverse proxy between an Apache web server and a Tomcat server. If you need any help setting up Tomcat, see How to install Apache Tomcat.

  • Start the servers

    Use the following commands to start Apache and Tomcat from the command line if they aren't already running:

    # start httpd.service
    # sudo $CATALINA_HOME/bin/startup.sh

    These commands should provide the following output:

    Modify httpd.conf

    Use nano to modify the httpd.conf, which is typically located in /etc/httpd/conf. Add the following lines to httpd.conf in the indicated section for loading modules:

    LoadModule proxy_module modules/mod_proxy.so
    LoadModule proxy_http_module modules/mod_proxy_http.so
    # mod_proxy setup.
    ProxyRequests Off
    ProxyPass /test http://localhost:8080
    ProxyPassReverse /test http://localhost:8080
    <Location "/test">
    Order allow,deny
    Allow from all
    </Location>

    The above lines will create the reverse proxy to the Tomcat server from http://localhost/test, assuming that Tomcat is listening to the default port of 8080.

    Save httpd.conf, which should now appear similar to the following screenshot:

    Test the reverse proxy

    Enter http://localhost/test in your browser. You should see the default Tomcat homepage as follows:

    Domain Registration

    Pay less for website domain names. Register your own .com, .net or .org for as low as $10.18 per year. We have everything you need to get online with your new domain.

    Website Builder

    Build an amazing website in just under an hour with Website Builder. Take advantage of designs created just for your industry and then customize them to reflect your one-of-a-kind idea.

    Website Security

    Protect your website and keep customers safe. Your comprehensive Website Security solution. Get peace of mind by securing your websites.

    cPanel Hosting

    Everything needed to give your website the high-performance home it deserves.  Protect transactions and secure your customer's data with a SSL Certificate
    Copyright © 2005 - 2024.  All rights reserved.  Privacy Policy