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 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

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

<Location /internal>

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 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.