HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Server Operation (http://www.howtoforge.com/forums/forumdisplay.php?f=5)
-   -   force ssl for website (http://www.howtoforge.com/forums/showthread.php?t=61027)

joey3002 20th March 2013 05:21

force ssl for website
 
I am trying to force https for a site whenever someone goes to the http of the site.

I am running nginx, I also have ispconfig 3.0.5.1

I have tried:
return 301 https://www.mysite.com$request_uri;

however, that just goes into an endless loop

Thanks

almere 20th March 2013 10:24

Try this:

Code:


server {
      listen        *:80;
      server_name    yourdomain.com;
      rewrite        ^ https://$server_name$request_uri? permanent;
}

server {

        listen *:443 ssl;
        ssl_certificate /var/www/clients/clientnumber/webnumber/ssl/yourdomain.com.crt;
        ssl_certificate_key /var/www/clients/clientnumber/webnumber/ssl/yourdomain.com.key;

### the rest of your code
}


joey3002 20th March 2013 15:46

thanks that worked!!

pharotek 18th November 2013 21:54

Quote:

Originally Posted by almere (Post 294314)
Try this:

Code:


server {
      listen        *:80;
      server_name    yourdomain.com;
      rewrite        ^ https://$server_name$request_uri? permanent;
}

server {

        listen *:443 ssl;
        ssl_certificate /var/www/clients/clientnumber/webnumber/ssl/yourdomain.com.crt;
        ssl_certificate_key /var/www/clients/clientnumber/webnumber/ssl/yourdomain.com.key;

### the rest of your code
}


Hi,

The above method is almost how I'd like to achieve HTTPS over HTTP. According to NGINX, It's best practise for NGINX to use:
Code:

return 301 https://$host$request_uri;
However, using this code or the above quoted method needs separate server blocks, correct? --Otherwise you will result with infinite loops.

How does one achieve this with the sites within ISPConfig 3.0.5.3 using the directives field?

Thank you.


All times are GMT +2. The time now is 15:36.

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