Welcome to Centmin Mod Community
Register Now

SSL force Http To Https

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Cr0w, Mar 29, 2016.

  1. Cr0w

    Cr0w Member

    165
    9
    18
    Mar 17, 2015
    Iran
    Ratings:
    +13
    Local Time:
    6:17 AM
    1.9.x
    5.5
    which is the simple way to force users use HTTPS Protocol .
    im using LE For http/2 support .

     
  2. eva2000

    eva2000 Administrator Staff Member

    55,381
    12,255
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,835
    Local Time:
    12:47 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Posted at centminmod.com/nginx_domain_dns_setup.html#httpsredirect

    key to testing is using 302 temp redirect first in a private incognito browser session otherwise the problems you can experience may end up being due to browser caching or 301 permanent redirects unless you clear browser cache and reboot local computer(s) and even then some web browsers don't let go of 301 permanent redirect browser cache that willingly :)
     
  3. Cr0w

    Cr0w Member

    165
    9
    18
    Mar 17, 2015
    Iran
    Ratings:
    +13
    Local Time:
    6:17 AM
    1.9.x
    5.5
    thanks George but i could't get that - >

    PHP:
    mv /usr/local/nginx/conf/conf.d/newdomain.com.conf /usr/local/nginx/conf/conf.d/newdomain.com.conf-disabled
    after disabling the vhost what should i do ?

    i think i must - >

    PHP:
    mv /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf  /usr/local/nginx/conf/conf.d/newdomain.com.conf
     
  4. eva2000

    eva2000 Administrator Staff Member

    55,381
    12,255
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,835
    Local Time:
    12:47 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    no need to move /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf just use that for https site
     
  5. Cr0w

    Cr0w Member

    165
    9
    18
    Mar 17, 2015
    Iran
    Ratings:
    +13
    Local Time:
    6:17 AM
    1.9.x
    5.5
    please explain me clearly ? i'm confused
    can you give me a screenshot or something ?

    if i disable my vhost my website will be down ! because i don't have any vhost configurations ! so now what ?
     
  6. eva2000

    eva2000 Administrator Staff Member

    55,381
    12,255
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,835
    Local Time:
    12:47 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    When you create a new nginx vhost domain via centmin.sh menu option 2 or /usr/bin/nv cli command line, you will create the Nginx vhost files and directories. You will get an outputted the path location where it will create the domain name's vhost conf file named newdomain.com.conf (and newdomain.com.ssl.conf if you selected yes to self signed SSL)
    • Nginx vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.conf
    • Nginx HTTP/2 SSL vhost conf path will be at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
    • Nginx Self-Signed SSL Certificate Directory at /usr/local/nginx/conf/ssl/newdomain.com
    • Vhost public web root will be at /home/nginx/domains/newdomain.com/public
    • Vhost log directory will be at /home/nginx/domains/newdomain.com/log
    So you'd have 2 nginx vhost files
    • http one at /usr/local/nginx/conf/conf.d/newdomain.com.conf which you rename to disable it
    • and https one at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf leaving you with that one to use for https site and then follow instructions at Nginx Vhost & NSD DNS Setup - CentminMod.com LEMP Nginx web stack for CentOS to add the http to https redirect into https vhost at /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf
     
  7. Cr0w

    Cr0w Member

    165
    9
    18
    Mar 17, 2015
    Iran
    Ratings:
    +13
    Local Time:
    6:17 AM
    1.9.x
    5.5
    i have problem with DNS , I made a ns1.mydomain.com + ns2.mydomain.com ( with my ipaddress ) and when i set my domain name servers to ns1 and ns2.mydomain.com
    i get error
    i want to know is centminmod DNS ( NSD ) Will automaticly make an child host ?
     
  8. eva2000

    eva2000 Administrator Staff Member

    55,381
    12,255
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,835
    Local Time:
    12:47 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Last edited: Mar 29, 2016
  9. Cr0w

    Cr0w Member

    165
    9
    18
    Mar 17, 2015
    Iran
    Ratings:
    +13
    Local Time:
    6:17 AM
    1.9.x
    5.5
    solved :) thanks (y) :chicken: Snapshot_2016-03-29_065503.png