Chapter 8. Reverse Proxy

Table of Contents

8.1. Overview
8.1.1. Examples
8.2. Usage
8.2.1. Configuring a Proxy Server
8.2.2. Configuring the Context Path
8.2.3. Configuring Proxy Filters
8.2.4. Deployment
8.3. Configuration Example

This chapter describes the basic concepts of a reverse proxy and how to use a reverse proxy to improve the web application performance.

A reverse proxy is a server that receives requests and forwards them to other servers, and receives responses and sends them to the requesting servers on behalf of the actual servers. A reverse proxy is used for load balancing and providing security by hiding the actual servers.

To use a reverse proxy, the application that activates the reverse proxy must be deployed. The examples in this chapter assume that the application name is ReverseProxy.

The following steps are required to use a reverse proxy:

  1. Configuring a proxy server

  2. Configuring a context path

  3. Configuring a proxy filter

  4. Deployment

To use a reverse proxy, first create data.xml in the "ReverseProxy/WEB-INF/config/" directory. This file contains information about the server that will be used as the proxy. In the file, configure the address of the server that will be used by the proxy and the rules that will be applied to the server.

Refer to "8.3. Configuration Example" for examples of configuring a proxy server.

The following are two server types can be used.

The data.xml file must contain the following syntax definitions from "ReverseProxy/WEB-INF/config/proxy-config.dtd" that is used to verify the syntax of data.xml.


JEUS supports two kinds of filter classes for reverse proxies.

In JEUS, the rewrite filter cannot be used without a proxy filter.

The following are examples of configuring web.xml of the WEB-INF directory for each filter type.

The following describe several cases of configuring Reverse Proxy/WEB-INF/config/data.xml.

CASE 1

If a proxy server at "www.proxy.com" is a proxy for "www.server1.com/content" for all requests and if "www.proxy.com/index.html" is requested, "www.server1.com/content/index.html" will be displayed. The following are the configurations for this example.

<config>
   <single-server>
   <domain-name>www.server1.com</domain-name>
   <path>/content</path>
   <rewriting>true</rewriting>
      <accept-everything-rule/>
   </single-server>
</config>

CASE 2

The requests to "www.proxy.com/remote" are forwarded to "www.server1.com", and requests to "www.proxy.com/internal" are forwarded to "www.server2.com:8080". Any other requests are forwarded to "www.server3.com". The following are the configurations for this example.

<config>
   <single-server>
   <domain-name>www.server1.com</domain-name>
   <rewriting>true</rewriting>
   <directory-rule>
      <path>/remote</path>
   </directory-rule>
   </single-server>
 
   <single-server>
   <domain-name>www.server2.com:8080</domain-name>
   <rewriting>true</rewriting>
   <directory-rule>
      <path>/internal</path>
   </directory-rule>
   </single-server>

   <single-server>
   <domain-name>www.server3.com</domain-name>
   <rewriting>true</rewriting>
   <accept-everything-rule/>
   </single-server>
</config>