Forum Moderators: phranque

Message Too Old, No Replies

redirect http to https on one page - Nginx server

         

pokra

9:46 pm on Jun 21, 2011 (gmt 0)

10+ Year Member



Hello. Greetings!

I have search the net on how to redirect http to https and found some code about this thing. But my problem is where to write the code when using Nginx server. For example, in Apache, we could use .htaccess to write codes accomplishing the redirect from http to https. I would like to know where to write in Nginx server. Please help. Thanks a lot!

wilderness

10:07 pm on Jun 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Nginx Rewrite [google.com]

robzilla

10:12 pm on Jun 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You'll have to directly edit the configuration file(s), such as nginx.conf or virtual.conf, depending on your set-up, since nginx has no support for .htaccess or any such method.

pokra

10:24 pm on Jun 21, 2011 (gmt 0)

10+ Year Member



Hello wilderness. Thank you for your reply. But the link you provided doesn't work.

Hello robzilla. Thanks a lot! So I need to edit things in nginx.conf or virtual.conf. Do you have any idea where I can find these files? Again thanks a ton!

robzilla

10:36 pm on Jun 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You'll need root access to your server. The nginx configuration files are located in the /etc/nginx/ and/or /etc/nginx/conf.d/ folder. However, if you do not know exactly what you're doing, you might end up breaking nginx altogether. I do not recommend attempting this on a live server, unless you don't mind the downtime that may result from your changes. Always make backups of the configuration files before you begin editing them.

As wilderness succinctly noted, a Google search for
nginx rewrite
is a good starting point -- but first try to get a decent grasp on the basic workings of the nginx configuration files.

g1smd

10:42 pm on Jun 21, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



@Wilderness: Links with hash bangs fail in WebmasterWorld as everything after the # is stripped.

Google put a huge amount of junk in their search URLs these days:
/#sclient=psy&hl=en&source=hp&q=nginx+rewrite&aq=2&aqi=g5&aql=&oq=&pbx=1&bav=on.2,or.r_gc.r_pw.&fp=30a8dd5b0420844b&biw=984&bih=541


There's a huge number of results in Google for [Nginx http https] several of which look like they might be useful.

pokra

11:19 pm on Jun 21, 2011 (gmt 0)

10+ Year Member



@robzilla: I guess I have to study more about Nginx. I have bookmarked some documentation about it through Google. Anyways, I don't want to mess things up again. Somehow I wrote some code into an .htaccess to a site running in Nginx just recently. When I learned the site I was working experienced a downtime, it drove me nuts! I am very happy by your help. Thank you so much!

@g1smd: I agree with you g1smd. I also bookmarked lots of them. But was really thinking about just using those codes again and apply to the .htaccess like what I did earlier. But I think I will stop doing that this time. :( But I learned a lot from you and from the experience I encounter. I am just a newbie after all. :) Thank you so much also for the help. I am just less than 1 day here in webmasterworld and I learned a lot!

wilderness

12:15 am on Jun 22, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



nginx+rewrite

robzilla

12:37 am on Jun 22, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Good luck, and welcome to WebmasterWorld. What you need shouldn't be too hard to accomplish, but they're obviously fragile things, these configuration files.

pokra

1:06 pm on Jun 22, 2011 (gmt 0)

10+ Year Member



@wilderness: thank you @wilderness.

@robzilla: thanks a lot! I agree. In time I will learn this thing. :)