do better redirection from http to https

Redirect using the 'return' directive and the built-in
variable '$request_uri' to avoid any capturing, matching
or evaluation of regular expressions.

It's best practice. See: http://wiki.nginx.org/Pitfalls#Taxing_Rewrites
This commit is contained in:
ikarus 2015-02-01 01:32:07 +01:00
parent 16422b4055
commit e330abd587
1 changed files with 4 additions and 1 deletions

View File

@ -7,7 +7,10 @@ server {
server_name $HOSTNAME;
root /tmp/invalid-path-nothing-here;
rewrite ^/(.*)$ https://$HOSTNAME/$1 permanent;
# Redirect using the 'return' directive and the built-in
# variable '$request_uri' to avoid any capturing, matching
# or evaluation of regular expressions.
return 301 https://$HOSTNAME$request_uri;
}
# The secure HTTPS server.