Configure Nginx redirect HTTP to HTTPS?

Jovani

Active member
Joined
Jul 10, 2012
Messages
338
Points
28
I'm trying to Nginx on my vps and as I knew then Google give better rankings for https protocol hence are there any ways to redirect from HTTP to HTTPS on Nginx? please suggest me :)
 

Alex Thompson

Moderator
Joined
Jun 6, 2013
Messages
651
Points
43
I'm trying to Nginx on my vps and as I knew then Google give better rankings for https protocol hence are there any ways to redirect from HTTP to HTTPS on Nginx? please suggest me :)
Hey Jovani,

After you installed SSL completely, you follow simple steps to redirect from http to htpps with nginx
The first, find the file nginx.conf or you can edit file in folder /etc/nginx/conf.d/

rewrite ^ https://$server_name$request_uri? permanent;
Finally, you will have file with content as following:
server {
server_name www.yourdomain.com;
rewrite ^ https://$server_name$request_uri? permanent;
}
Restart Nginx
service nginx restart
Hope it helps!
 
Latest threads
Replies
0
Views
590
Replies
2
Views
789
Recommended threads
Replies
1
Views
2,797
Replies
3
Views
2,195
Replies
23
Views
9,843
Replies
1
Views
2,323

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top