Tuesday, April 10, 2012

Redirect Non-SSL requests to SSL on Nginx without Redirect Loop

Add these lines to your Nginx server{} block:
if ($scheme = "http") { rewrite ^ https://$server_name$request_uri? permanent; }

There is another way to do the same thing as:
if ($ssl_protocol = "") { rewrite ^ https://$server_name$request_uri? permanent; }

0 comments:

Post a Comment