We have the following scenario we are trying to proxy requests to two backend domains through the same public address.
<VirtualHost *:443>
SSLEngine On
SSLProxyEngine On
SSLProxyVerify none
ServerName public.mycompany.com
SSLCertificateFile "/etc/pki/tls/certs/public.mycompany.com.pem"
SSLCertificateKeyFile "/etc/pki/tls/private/public.mycompany.com.key.pem"
ProxyPass / https://private.backend.com
ProxyPassReverse / https://private.backend.com/
ProxyPassReverseCookieDomain ".private.backend.com" ".mycompany.com"
ProxyPassReverseCookieDomain ".private.backend.com" ".public.mycompany.com"
ProxyPass /bakend-login https://login.backend.com
ProxyPassReverse /bakend-login https://login.backend.com/
</VirtualHost>
The public domain is (hypothetically for illustrative purposes) public.mycompany.com
.
The backend domains are login.backend.com
and private.backend.com
We are using the following mod_proxy directives
The first proxy directives work fine and we can see redirects from the backend to itself being replaced with the public hostname as in
Location: https://private.backend.com/somepath
becoming https://public.mycompany.com/somepath
However, if the redirect from the backend is to login.backend.com, we are not able to replace the hostname with the public domain before returning to the client. What we would like to do is replace
Location: https://login.backend.com
with Location: https://public.mycompany.com/backend-login
Is this possible with mod_proxy?
We tried using mod_headers at the end of all directives to replace the header, but we were not able to. This is what we tried.
Header edit Location "^https:\/\/login\.backend\.com\/(.*)$" https://public.mycompany.com/bakend-login/$1
We also tried another proxy directive for the redirect, but that doesn’t seem like it would work.
ProxyPass /bakend-login https://login.backend.com
ProxyPassReverse /bakend-login https://login.backend.com/