LiteSpeed Technologies
Download Download     Blog Blog     Wiki Wiki     Forum Forum     Store     Contact Contact    

Use rewrite rule to redirect http to https connection

For first entry server accepting connection from unsafe WAN:

rewriteCond %{HTTPS} !on
rewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

If used on another server behind internal load balancers, ssl off-loaders:

rewriteCond %{HTTPS} !on
rewriteCond %{HTTP:X-Forwarded-Proto} !https
rewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

The difference in the two rules are the check for X-Forwarded-Proto header which can be spoofed and thus not a good check to use at the first point of contact from WAN.

 
litespeed_wiki/https_redirect.txt · Last modified: 2011/06/06 00:19 by xing
 
© Copyright 2003-2011 LiteSpeed Technologies, Inc. All rights reserved. Privacy Policy.