Reputation: 11
I have to redirect the users to the SSL zone, if someone write http://www.example.com I Must redirect him to https://
How can I do it automatically using Nginx ?
Thank you
Upvotes: 1
Views: 5375
Reputation: 511
The following approach is better according to
http://wiki.nginx.org/Pitfalls#Taxing_Rewrites
server {
listen 80;
server_name signup.mysite.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
Upvotes: 0
Reputation: 1712
For the record, it looks like this is an even better approach to it since it avoids regular expressions altogether:
server {
listen 80;
server_name myserver.com;
return 301 https://$server_name$request_uri;
}
Upvotes: 1
Reputation: 89
server {
listen 80;
server_name _ *;
rewrite ^(.*) https://$www.example.com$1 permanent;
}
server {
listen 443;
server_name _ *;
}
Upvotes: 0