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
1
Views
91
Replies
1
Views
96
Replies
1
Views
160
Replies
1
Views
196
Replies
1
Views
277
Recommended threads
Replies
2
Views
2,639
Replies
0
Views
3,169
Replies
7
Views
4,667
Replies
7
Views
1,620

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