Force HTTPS with AWS Elastic load balancer
- by panos2point0
I need to redirect all incoming HTTP traffic to HTTPS on my elastic load balancer.
I tired using Apache mod_rewrite:
RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule !/status https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Taking advantage of the X-Forwarded-Proto header added by the load balancer, this rule should instruct the users browser to request the HTTPS version of the same URL.
So far It doesn't work (no redirection happens).
What am I doing wrong?
Is there a better way to do this?