4.12 Apache Reverse Proxy

An Apache server can be configured to work as a reverse-proxy server.

A reverse proxy server appears to the client just like an ordinary web server.

No special configuration on the client is necessary.

The client makes ordinary requests for content in the name-space of the reverse proxy.

The reverse proxy then decides where to send those requests and returns the content as if it was itself the origin.

A typical usage of a reverse proxy is to provide Internet users access to a server that is behind a firewall.

Reverse proxies can also be used to balance load among several back-end servers, or to provide caching for a slower back-end server.

In addition, reverse proxies can be used simply to bring several servers into the same URL space.

If you require a more flexible reverse-proxy configuration, see the RewriteRule directive with the [P] flag.

For more information refer to Apache HTTP Server Version 2.4: Apache Module mod_proxy

Following is an example IBM Apache Server Configuration:

 

# Apache Configuration - Reverse Proxy

#

LoadModule proxy_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM

LoadModule proxy_http_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM

# LoadModule proxy_ftp_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM

# LoadModule proxy_connect_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM

#

Options None

Listen 10.2.0.170:2334

ServerRoot /www/jsmproxy

DocumentRoot /www/jsmproxy/htdocs

# DefaultFsCCSID  37

# DefaultNetCCSID 819

# ServerUserID USERPROFILE

#

LogLevel Warn

LogCycle Daily

ErrorLog logs/error_log

CustomLog logs/access_log combined

LogFormat "%{User-agent}i" agent

LogFormat "%{Referer}i -> %U" referer

LogFormat "%{Cookie}n \"%r\" %t" cookie

LogFormat "%h %l %u %t \"%r\" %>s %b" common

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

#

SetEnvIf "User-Agent" "Mozilla/2" nokeepalive

SetEnvIf "User-Agent" "JDK/1\.0" force-response-1.0

SetEnvIf "User-Agent" "Java/1\.0" force-response-1.0

SetEnvIf "User-Agent" "RealPlayer 4\.0" force-response-1.0

SetEnvIf "User-Agent" "MSIE 4\.0b2;" nokeepalive

SetEnvIf "User-Agent" "MSIE 4\.0b2;" force-response-1.0

#

# Use name-based virtual hosting

NameVirtualHost 10.2.0.170

#

<VirtualHost 10.2.0.170>

  # The first virtual host directive will become the default host

  Options None

  ServerName SERVER1

  TimeOut 3000

  ProxyReverse On

  ProxyRequests Off

  ProxyTimeOut 3000

  <Proxy *>

    Order Allow,Deny

    Allow from all

  </Proxy>

  #

  # Pass all requests

  # ProxyPass / http://server1:1099/

  # ProxyPassReverse / http:// server1:1099/

  #

  # Pass only CGI requests

  ProxyPass /cgi-bin/ http://server1:1099/cgi-bin/

  ProxyPassReverse /cgi-bin/ http://server1:1099/cgi-bin/

</VirtualHost>

#

<Directory />

  Options None

  Order Allow,Deny

  Deny from all

  AllowOverride None

</Directory>

#

<Directory /www/jsmproxy/htdocs>

  Options None

  Order Allow,Deny

  # Deny from all

  Allow from all

  AllowOverride None

</Directory>