Join the community today
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:
    8:10 PM
    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

    28,935
    6,569
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,749
    Local Time:
    1:40 AM
    Nginx 1.13.x
    MariaDB 5.5
    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 :)
     
    • Like Like x 1
  3. Cr0w

    Cr0w Member

    165
    9
    18
    Mar 17, 2015
    Iran
    Ratings:
    +13
    Local Time:
    8:10 PM
    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

    28,935
    6,569
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,749
    Local Time:
    1:40 AM
    Nginx 1.13.x
    MariaDB 5.5
    no need to move /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf just use that for https site
     
    • Like Like x 1
  5. Cr0w

    Cr0w Member

    165
    9
    18
    Mar 17, 2015
    Iran
    Ratings:
    +13
    Local Time:
    8:10 PM
    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

    28,935
    6,569
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,749
    Local Time:
    1:40 AM
    Nginx 1.13.x
    MariaDB 5.5
    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
     
    • Friendly Friendly x 1
  7. Cr0w

    Cr0w Member

    165
    9
    18
    Mar 17, 2015
    Iran
    Ratings:
    +13
    Local Time:
    8:10 PM
    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

    28,935
    6,569
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,749
    Local Time:
    1:40 AM
    Nginx 1.13.x
    MariaDB 5.5
    Last edited: Mar 29, 2016
    • Like Like x 1
  9. Cr0w

    Cr0w Member

    165
    9
    18
    Mar 17, 2015
    Iran
    Ratings:
    +13
    Local Time:
    8:10 PM
    1.9.x
    5.5
    solved :) thanks (y) :chicken: Snapshot_2016-03-29_065503.png
     
    • Like Like x 1