How can I force all requests to be SSL when using EC2 load balancer?

Posted by chris on Server Fault See other posts from Server Fault or by chris
Published on 2012-12-03T15:47:37Z Indexed on 2012/12/03 17:07 UTC
Read the original article Hit count: 194

I currently have a single EC2 instance which is forcing all requests to be secure by using mod_rewrite:

RewriteEngine      On
RewriteCond    %{SERVER_PORT}   !443
RewriteRule        ^(.*)$     https://%{HTTP_HOST}$1 [R,L]

I am planning on moving to a load balanced setup, with multiple back-end instances. If I set up my EC2 load balancer with my certs, do I need to use SSL to communicate between the LB and my instances?

If not, is it as simple as replacing the RewriteCond with

RewriteCond %{HTTP:X-Forwarded_Proto} ^http$

Edit: I tried using the x-forwarded-proto, but it does not appear to work. Is there another way to detect if someone is connected to the LB via SSL?

© Server Fault or respective owner

Related posts about amazon-ec2

Related posts about ssl