force ssl for website

Discussion in 'Server Operation' started by joey3002, Mar 20, 2013.

  1. joey3002

    joey3002 New Member

    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

    I have tried:
    return 301$request_uri;

    however, that just goes into an endless loop

  2. almere

    almere ISPConfig Developer ISPConfig Developer

    Try this:

    server {
           listen         *:80;
           rewrite        ^ https://$server_name$request_uri? permanent;
    server {
            listen *:443 ssl;
            ssl_certificate /var/www/clients/clientnumber/webnumber/ssl/;
            ssl_certificate_key /var/www/clients/clientnumber/webnumber/ssl/;
    ### the rest of your code
  3. joey3002

    joey3002 New Member

    thanks that worked!!
  4. pharotek

    pharotek New Member


    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:
    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 using the directives field?

    Thank you.

Share This Page