HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=27)
-   -   [ISP3/Nginx] https only site (http://www.howtoforge.com/forums/showthread.php?t=59752)

Dodge 30th November 2012 22:27

[ISP3/Nginx] https only site
 
Hey there,

i just installed ISP3 on my new Server(Debian6) and so far everything is running fine, but while setting up my sites, i came across a small problem.

I want one of my sites https only. http requests should be redirected to https. https works without problems, bit i cant find a way to redirect http to https or disable http for that site at least.

i allready tried to use the isp redirect settings for my domain with the result of an endles redirect :(
i even tried to add a redirect block with the config option to add custom directives to nginx vhost config but that does not work as the block would be after the actual vhost block and so never matched as the block itself matches :/


so: is there a way to disable http or redirect http -> https?


thanks in advance

webguyz 30th November 2012 23:08

Perhaps something like this in the .htaccess at the root of your website:

-----------------------------------------------------------------
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
-----------------------------------------------------------------

Dodge 1st December 2012 15:29

Hey webguyz,

thank you for your reply. but as i have written, i'm using nginx as webserver so there is no .htaccess support

webguyz 1st December 2012 15:36

Oops. Keep forgetting that about nginx. Must be why I use Apache, for compatability with the rest of the world :)

Good Luck!

falko 2nd December 2012 11:59

Use this in the nginx Directives field:

Code:

if ($scheme != "https") {
                rewrite ^ https://$host$request_uri? permanent;
}


Dodge 2nd December 2012 12:10

Quote:

Originally Posted by falko (Post 289021)
Use this in the nginx Directives field:

Code:

if ($scheme != "https") {
                rewrite ^ https://$host$request_uri? permanent;
}


works perfectly. thanks! :))


All times are GMT +2. The time now is 19:28.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.