Force HTTPS on Apache behind Nginx load balancer

How to force HTTPS on Apache with Nginx load balancer

Edit httd.conf

Add the following configuration in the Apache configuration file httd.conf.

<VirtualHost *:80>
...
RewriteEngine on
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</VirtualHost>
Last modified April 22, 2024: added useful options (#171) (7e11b10)