How to Configure Apache Reverse Proxy Domain Url to Specific Url on Localhost

I am stuck with an issue i have with configuring apache reverse proxy server. I want to use an url eq.: and my reverse proxy should be configured using .

The problem currently when i navigate to it is replaced with .

How do i go about configuring this? My configuration:

<VirtualHost *:443>
    SSLEngine on
    ServerName software.testsite.net
    SSLProxyEngine On

    SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
    SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
    SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"

    RequestHeader edit Destination ^https http early

    <Location />
        RedirectMatch ^/$ 
        ProxyPass 
        ProxyPassReverse 
    </Location>
</virtualhost>

<VirtualHost *:80>
    ProxyPreserveHost On
    ProxyVia on
    RewriteEngine on
    ProxyRequests     Off
    SSLProxyEngine On
    SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
    SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
    SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"

    # used for enforcing http to https
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*)  [R,L]

    ServerName software.testsite.net
    <Location />
        ProxyPass 
        ProxyPassReverse 
    </Location>

</VirtualHost>

1 Answer

I finally got it working. Not sure if this is the way it is supposed to be done though.

<VirtualHost *:80>
    ServerName software.testsite.net

    DocumentRoot "${SRVROOT}/htdocs/software"
    DirectoryIndex index.html

    ProxyPreserveHost On
    ProxyVia on
    RewriteEngine on
    ProxyRequests     Off

    # used for enforcing http to https
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*)  [R,L]

    SSLProxyEngine On
    SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
    SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
    SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"

    <Location /customapp>
        ProxyPass 
        ProxyPassReverse 
    </Location>
</VirtualHost>

<VirtualHost *:443>
    ServerName software.testsite.net

    DocumentRoot "${SRVROOT}/htdocs/software"
    DirectoryIndex index.html

    RequestHeader edit Destination ^https http early
    SSLEngine on
    SSLProxyEngine On
    SSLCertificateFile "${SRVROOT}/certs/testsite.crt"
    SSLCertificateKeyFile "${SRVROOT}/certs/testsite.key"
    SSLCertificateChainFile "${SRVROOT}/certs/testsite.ca-bundle"

    <Location /customapp>
        RedirectMatch ^/$ 
        ProxyPass 
        ProxyPassReverse 
    </Location>
</virtualhost>

<!DOCTYPE html>
<html>
   <head>
      <title>HTML Meta Tag</title>
      <meta http-equiv = "refresh" content = "1; url ="/>
   </head>
   <body>
      <p>Redirecting...</p>
   </body>
</html>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne

Robert Thorne

Automotive & Future Transportation Editor

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.

Share this article
Twitter Facebook Pinterest