Last active
January 20, 2016 06:40
-
-
Save dashr/c2dff10f4edb82f904b1 to your computer and use it in GitHub Desktop.
Nginx: Send all 80 to 443
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sites-available/production <-- in same VirtualHost container as the 443 one, above it | |
server { | |
listen 80; | |
server_name sample.com www.sample.com; | |
rewrite ^(.*) https://sample.com$1 permanent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
As stated in http://nginx.org/en/docs/http/converting_rewrite_rules.html it is ineffective to use rewrite when no actual rewriting is done.
server {
listen 80;
server_name sample.com www.sample.com;
return 301 https://sample.com$request_uri;
}
Just adding this information here if someone comes across it in search for information on how to do it. :)