Sunday, October 24, 2021

microHOWTO: Configure Apache as a reverse proxy

microHOWTO: Configure Apache as a reverse proxy

Use the ProxyPass directive to map the required local path to the corresponding remote URL

The ProxyPass directive creates a mapping from a path within the local web site to a given remote URL. In this instance the local path is /internal and it should be mapped to http://internal.example.com/public. There are two ways in which this can be expressed. ProxyPass has a two-argument form, where both local path and remote URL are specified explicitly:

ProxyPass /internal http://internal.example.com/public

It also has a single-argument form, where the local path is implied by the context:

<Location /internal>
 ProxyPass http://internal.example.com/public
</Location>

The effect is the same either way. The mapping applies to any location within the subtree rooted at the given path, so (for example) the configuration above would cause /internal/logo.png to be mapped to http://internal.example.com/public/logo.png. Trailing slash characters are significant:

  • If the slash is included then only the content of the specified directory is mapped, not the directory itself.
  • Without the slash, both directory and content are mapped.

For this reason, the path and the URL should either both end with a slash or both end without one.

http://www.microhowto.info/howto/configure_apache_as_a_reverse_proxy.html