Welcome to Centmin Mod Community
Register Now

Nginx Disable https nginx vhost .conf file

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by pamamolf, Feb 8, 2016.

Tags:
  1. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    Hi


    I just create a vhost and i let the menu create an https config also for it...

    All is working great but now i want to disable the https on mydomain.com..

    I rename the mydomain.com.ssl.conf to mydomain.com.ssl.disabled and i restart Nginx but https site is loading again :(

    How can i disable it?

    Thanks
     
    Last edited: Feb 8, 2016
  2. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  3. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    nope didn't touch anything related....

    Normal www.mydomain works and doesn't push me to https..
     
  4. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    if you didn't then they should be separate and never http to https redirect

    try clearing browser cache and restart your browser

    is it a subdomain or top domain site ? if it's subdomain, did the main domain enable HSTS with include subdomain option ?
     
  5. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    Try it with another browser also that never open it there and is still loading again....cleared cache also doesn't work.
     
  6. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    do curl header on each and see what type of redirect it is whether it's 301 or 302
    Code:
    curl -I http://domain.com
    curl -I http://www.domain.com
    if they don't redirect in SSH curl, then it's at your browser level/browser cache

    if it's 301 or 302, check your http and https vhost for such redirects
     
  7. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    301 for the first and nothing for the second....

    And this is working great as i want the domain.com to redirect to www.

    maybe to disable also the ssl.conf ? But all info there are commented....
     
  8. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    FYI if you want www.domain.com to not parse on forums use PLAIN tag
    Code:
    [PLAIN]www.domain.com[/PLAIN]
    You at one time must of tried a http to https redirect for https via 301 ? that's why i always suggest 302 temp redirects first before deciding if 301 is right as 301 gets permanently cached in web browsers and not as easy to clear

    see Chrome Clear Redirect Cache
     
  9. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    I am not getting any redirect from http to https not 301 or 302.
     
  10. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    oh on second thought if this happens in non-browser curl header check then it ain't just browser, you still have server setup for 301 redirect in one of your vhosts
     
  11. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    I am getting redirect from:

    Code:
    http://domain.com
    to
    http://www.domain.com
    But no https redirect...

    After the installation i just go to:

    Code:
    https://www.domain.com
    so i can check it and then try to disable it.

    I didn't even try to use none www in https to see if it works.....
     
  12. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    oh i see that happens in you http vhost so double check
     
  13. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    My normal domain.com.conf doesn't have anything related to https and the https conf file is disabled my renamed it to .disabled so it shouldn't work..

    Try to create a new vhost by adding a new domain and create http and https ssl certificate and browse to the https version of it.
    Then try to disable it and check it if it loads again on browser.
     
  14. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    post contents of both http and https vhosts
     
  15. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    Code:
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   80;
                server_name domain.com;
                return 301 $scheme://www.domain.com$request_uri;
           }
    
    server {
    
    #limit_conn alpha 10;
    #limit_req zone=delta burst=70 nodelay;
    
      server_name domain.com;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      #add_header X-Frame-Options SAMEORIGIN;
      #add_header X-Xss-Protection "1; mode=block" always;
      #add_header X-Content-Type-Options "nosniff" always;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/domain.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/domain.com/log/error.log;
    
      root /home/nginx/domains/domain.com/public;
    
      # prevent access to ./directories and files
      location ~ (?:^|/)\. {
       deny all;
      }
    
      location / {
    
    # block common exploits, sql injections etc
    include /usr/local/nginx/conf/block.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # Shows file listing times as local time
      #autoindex_localtime on;
    
      # Enable for vBulletin usage WITHOUT vbSEO installed
      try_files    $uri $uri/ /index.php;
    
      }
    
    location ^~/admin/ {
    auth_basic "Private";
    auth_basic_user_file /usr/local/nginx/conf/htpasswdad;
    include /usr/local/nginx/conf/php.conf;
    }
    
       location ~^(/uploads/).*(\.php)$ {
            deny     all;
        }
    
       location ~^(/uploads/gadgets/images/).*(\.php)$ {
            deny     all;
        }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    https file is disabled: domain.com.ssl.disabled
     
  16. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    change
    Code:
    $scheme://
    to
    Code:
    http://
     
  17. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    oh actual problem is in main redirected server context you don't have an server_name for www.
    Code:
    server_name domain.com;
    should be
    Code:
    server_name www.domain.com;
     
  18. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    Ok but the problem is not the $scheme or the www as my problem is not related at all with any redirections :)

    I am not getting redirected to https.

    when i use simple domain.com i am getting the http version of it as it should .

    Only if i go to https i can see that exist and loads.

    But as i rename the domain.ssl.conf to domain.ssl.disabled and restart nginx then the https must not load at all.

    Confuse you? :(
     
  19. eva2000

    eva2000 Administrator Staff Member

    55,424
    12,257
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,839
    Local Time:
    7:47 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    oh rename to domain.ssl-disabled with hyphen and restart nginx and php-fpm and see
     
  20. pamamolf

    pamamolf Well-Known Member

    4,101
    428
    83
    May 31, 2014
    Ratings:
    +838
    Local Time:
    12:47 AM
    Nginx-1.26.x
    MariaDB 10.6.x
    Ok i did it but it loads again :(

    domain.ssl-disabled

    and restart nginx and php-fpm....