I'm configuring apache to proxy SSL requests to a local backend server. Here are the relevant parts of the virtual host:
<VirtualHost *:443>
...
SSLEngine on
SSLCertificateFile /path/to/server.crt
SSLCertificateKeyFile /path/to/server.key
RewriteEngine On
<Proxy balancer://unicornservers>
BalancerMember http://127.0.0.1:8080
</Proxy>
# Redirect all non-static requests to unicorn
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://unicornservers%{REQUEST_URI} [P,QSA,L]
ProxyPassReverse / balancer://unicornservers/
ProxyPreserveHost on
...
</VirtualHost>
When I use curl to access the server (curl -vk https://example.com
), the backend server performs a redirect to /login
, as it is supposed to.
The problem is, apache is not rewriting the Location
header properly. It returns a location of http://example.com/login
instead of https://example.com/login
.
Is there somewhere in my config where I need to tell apache to use https
for the ProxyPassReverse
rewrite?