SSL redirect on EC2 instance behind SSL terminating load balancer
6,579
untested.. but I try this
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Related videos on Youtube
Author by
rix
Updated on September 18, 2022Comments
-
rix over 1 year
I'm trying to redirect all url's to https in a web application.
I have an ec2 instance behind an elastic load balancer. SSL is terminated on the load balancer.
Any attempts at redirection end up giving me the familiar 'this page is requesting in a way which will never complete'.
The load balancer forwards 443 and 80 to port 80 on the instance.
This is what I have in my .htaccess.
RewriteCond %{X-FORWARDED-PROTO} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Does anyone have any idea how to accomplish this? Kind thanks,
-
rix about 12 yearsYes! Thank you so much. Been struggling with this for a while now. Much appreciated. Please upvote this is answer if you find this a help. Thank you...
-
Bill Rosmus about 11 yearsthe link is broken
-
Tim about 11 yearsSolution still works. Some explanation could be found here: docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/…
-
Ben Sinclair over 9 yearsWorked for me. Tested today