Apache Reverse Proxy Guide

From D-Wiki

Apache Reverse Proxy Guide

Basic examples of a reverse proxy config example.

HTTP-Example

<VirtualHost {IP-Address}:80>
  ServerName {WEBSITE}
  ServerAlias {WEBSITE-ALIAS}

  ProxyPreserveHost On
  ProxyRequests off
  AllowEncodedSlashes NoDecode
  ProxyPass /.well-known !
  Redirect permanent / {REDIRECT-WEBSITE}
</VirtualHost>

You could for example redirect to the https version of the same website with a reverse proxy. Or you could just use the "ProxyPass" property like that ProxyPass / {LOCAL-SERVICE} nocanon if you want just the plain reverse proxy assignment.

If you want to recieve requests from other types of ports/protocols/whatever you need to replace the port "80" after the IP-Address to the corresponding port and the other parameters. Redirections also work for alternative protocols like Gemini or Gopher, not only http/https.

HTTPS-Example

<VirtualHost {IP-Address}:443>
        ServerName {WEBSITE}
        ServerAlias {WEBSITE-ALIAS}
        SSLEngine on
        SSLCertificateFile "{PATH_TO_CERT_FILE}"
        SSLCertificateChainFile "{PATH_TO_CERT_CHAIN_FILE}"
        SSLCertificateKeyFile "{PATH_TO_CERT_PRIVATE_KEY_FILE}"
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        ProxyPreserveHost Off
        ProxyRequests off
        AllowEncodedSlashes NoDecode

        ProxyPass / {LOCALHOST-ADDRESS-TO-SERVICE}

        <Location /&gt;
          Order allow,deny
          Allow from all
        </Location>
</VirtualHost>