Configure Nginx redirect HTTP to HTTPS

Currently the demand of using security protocol SSL for websites are quite popular because Google has increased the importance of ranking for this site. After installing the SSL success, how to redirect all url from HTTP to HTTPS with the nginx, please refer to this tutorial.

Edit nginx configuration file (/etc/nginx/nginx.conf). Add or modify the redirect structure follows:

rewrite ^ https://$server_name$request_uri? permanent;

Eventually you will be file with content similar to this:

server {
 server_name www.example.com;
 rewrite        ^ https://$server_name$request_uri? permanent;
 }

Restart Nginx:

service nginx restart

 

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz