We are using reverse proxy to allow users from outside the firewall to access to services on an internal server. However although we use the ProxyPreserveHost
directive, requests with the URL http://project.domain.com/index.html
result in http://internal.server/index.html
instead of the expected http://project.domain.com/index.html
.
Here is our virtual host definition:
<VirtualHost *:443>
ServerName "https://project.domain.com"
SSLEngine on
SSLCertificateFile /etc/ssl/our.cer
SSLCertificateKeyFile /etc/ssl/private/our.key
ProxyRequests Off
ProxyVia Off
<Proxy *>
Require all granted
</Proxy>
ProxyPreserveHost On
ProxyPass / http://internal.server:80/
ProxyPassReverse / http://internal.server:80/
</VirtualHost>
The problem was that the target of the ProxyPass
was itself redirected to https://internal.server
.
When we changed ProxyPass
and ProxyPassReverse
target to https://internal.server
(bypassing the redirection), the ProxyPreserveHost
directive worked.