Learn about Centmin Mod LEMP Stack today
Register Now

Domains maintenaince mode

Discussion in 'Install & Upgrades or Pre-Install Questions' started by EckyBrazzz, May 26, 2019.

  1. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    Maybe something that is asked before, but how to set some/several domains into maintenaince mode and not the entire server?
     
  2. eva2000

    eva2000 Administrator Staff Member

    40,276
    8,926
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,746
    Local Time:
    10:36 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    Are you referring to 123.09beta01's native site maintenance mode feature Beta Branch - sitestatus maintenance mode ?

    If so, I guess you can also make a copy of the feature by copying the following files and replacing their call references in your intended nginx vhosts and then making a copy of sitestatus command just for those copied files which operate on global server wide basis for all nginx vhosts and make the copies only work for a specific nginx vhost/site(s) you intend to
    • /usr/local/nginx/conf/503include-main.conf
    • /usr/local/nginx/conf/503include-only.conf
    • /usr/local/nginx/conf/sitestatus.conf
    • /usr/local/nginx/conf/maintenance.conf
    • /usr/bin/sitestatus script which is located at tools/sitestatus.sh
    • /home/nginx/domains/yourdomain.com/public/maintenance.html
    • /usr/local/nginx/conf/php.conf and any copies which reference the include file
      /usr/local/nginx/conf/503include-only.conf inside
    How these files work together for server wide sitestatus maintenance mode in 123.09beta01 are outlined at Beta Branch - sitestatus maintenance mode

    or technically you can modify /usr/local/nginx/conf/maintenance.conf and add the domains you do not want to include in site maintenance to the $exclude_url map with a value of 1
    Code (Text):
        map $http_host$uri $exclude_url {
             default                                                0;
             "~^newdomain1.com/js/jquery.fittext.js"                1;
             "~^newdomain1.com/blog/js/jquery.fittext.js"           1;
        }
    


    or another way is for each nginx vhost you do not want to include in server wide site maintenance mode, edit their nginx vhosts and comment out their /usr/local/nginx/conf/503include-main.conf and /usr/local/nginx/conf/503include-only.conf include file references and use a copy of /usr/local/nginx/conf/php.conf without reference to the include file
    /usr/local/nginx/conf/503include-only.conf inside
     
    • Informative Informative x 3
  3. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    Like the easy/technically way, but maybe a suggestion for a new (beta)realease. If you have a lot of domains all suggestions above are a lot of work, so adding them automatically when creating a vhost in /usr/local/nginx/conf/maintenance.conf with value 0 would be very nice. Especially when you work on many domains. Just change the domain value to 1, restart/reload nginx and you're done. Even better would be to add afterward a functionality to it like sitestatus off newdomainX.com
    Code (Text):
    Code (Text):
       map $http_host$uri $exclude_url {
            default                                                0;
            "~^newdomain1.com/js/jquery.fittext.js"                1;
            "~^newdomain1.com/blog/js/jquery.fittext.js"           1;
       }
    
    
     
    • Like Like x 1
    • Informative Informative x 1
  4. pamamolf

    pamamolf Premium Member Premium Member

    3,304
    318
    83
    May 31, 2014
    Ratings:
    +588
    Local Time:
    3:36 PM
    Nginx-1.13.x
    MariaDB 10.1.x
    sitestatus off mydomain.com seems better for me :)
     
    • Agree Agree x 2
    • Informative Informative x 1
  5. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    For me too, but for that to work /usr/local/nginx/conf/maintenance.conf needs the mydomain.conf
     
  6. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    Ha, just updated /usr/local/nginx/conf/maintenance.conf with all domains and set several to 1; Added several IP's for developers that update some sites. Real life saver!

    Some of these sites are/were a mess, so rather put them into maintenance mode. The maintenance page says "Site" not "Server". Translated them to have the correct language and changed the color to a dark theme, as this is more modern. Most applications today have an option for a dark mode.
    Onderhoud.png

    Code (Text):
    sitestatus off
    is set as default on my server now!

    Thanks, @eva2000 for the info, just a suggestion make "sitestatus off mydomain.com" work;);)
     
    Last edited: May 27, 2019
    • Informative Informative x 1
  7. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    hmm, just did some testing with some VPN's, but when using sitestatus off all site go into that mode, doesn't make any difference if I put 0; or 1; so what I posted above doesn't work.
     
    Last edited: May 27, 2019
  8. eva2000

    eva2000 Administrator Staff Member

    40,276
    8,926
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,746
    Local Time:
    10:36 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    VPN would change your detected IP so make sure that is whitelisted
     
  9. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    The idea was to put a selected site into maintenance mode for all visitors except the whitelisted IP's. Not the entire server. The test with several VPN's proved that it did not work.

    TIP: I use Softether VPN from the University of Japan, it's free to use SoftEther VPN Project - SoftEther VPN Project
     
  10. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    Still struggling with the fact that it won't work, I can't put the selected sites into maintenance mode. The whole server goes into maintenance mode when using sitestatus off
    Code (Text):
    Code (Text):
       map $http_host$uri $exclude_url {
           default                                                0;
           "~^newdomain1.com/js/jquery.fittext.js"               1;
           "~^newdomain2.com/js/jquery.fittext.js"               0;
           "~^newdomain3.com/js/jquery.fittext.js"               1;
           "~^newdomain4.com/js/jquery.fittext.js"               1;
           "~^newdomain5.com/js/jquery.fittext.js"               1;
           "~^newdomain6.com/js/jquery.fittext.js"               0;
       }
    


    And yes, whitelisted IP's and checked it with a VPN and without VPN.
     
  11. eva2000

    eva2000 Administrator Staff Member

    40,276
    8,926
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,746
    Local Time:
    10:36 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    for domains only you'd need to set them as
    Code (Text):
    ~^newdomain1.com/ 1;
    

    so $http_host = newdomain1.com and $uri = /
     
  12. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    Still no go. Tested domain to 1; and other to 0; but still the same effect. All go into maintenance mode.
     
  13. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    As with all good things, sometimes it ends. Time to get some sleep :)
    Project_CMM_7232.png
     
  14. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    It seems that the maintainance.conf completely ignores the setting with the domians. The whitlisted IP works.

    Also tried to change the default in sitestatus.conf from 1; to 0; but it gets overwritten to 1; when I run sitestatus off
     
  15. eva2000

    eva2000 Administrator Staff Member

    40,276
    8,926
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,746
    Local Time:
    10:36 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    that's expected when running sitestatus command as it controls the value in sitestatus.conf

    as to excluding on url basis, will have to investigate but for now you will need to probably use other methods outlined in post #2 above for separate vhost include files
     
  16. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    @eva2000 How to set reserved domains to have to maintanance page instead the Nginx test page when pointig a domain with IP to the server. Now I get the
    Centmin Mod Nginx Test Page
     
  17. eva2000

    eva2000 Administrator Staff Member

    40,276
    8,926
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,746
    Local Time:
    10:36 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
  18. eva2000

    eva2000 Administrator Staff Member

    40,276
    8,926
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,746
    Local Time:
    10:36 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    example using nv command to create nginx vhost outlined at Install - Quick Centmin Mod Install + Nginx Vhost Site + MySQL Database Setup with letsencrypt ssl default Nginx HTTP/2 HTTPS with LETSENCRYPT_DETECT='y' enabled in persistent config file already at /etc/centminmod/custom_config.inc

    ensure domain.com and www.domain.com DNS A records point to centmin mod server IP first and then changing your desired pure-ftpd virtual ftp username from ftpusername and desired domain from domain.com
    Code (Text):
    nv -d domain.com -s lelived -u ftpusername
    cd /home/nginx/domains/domain.com/public
    mv index.html index-old.html
    cp -a maintenance.html index.html
    ngxrestart
    

    • 1st command is SSH command line equivalent of centmin.sh menu option 2 which creates domain.com nginx http/2 https default site with letsencrypt ssl certification
    • 2nd command changes to domain.com public web root as outlined at Centmin Mod Configuration Files - CentminMod.com LEMP Nginx web stack for CentOS
    • 3rd command moves existing default index.html shown when visiting domain.com and renames it index-old.html
    • 4th command makes copy of maintenance.html file as new index.html
    • 5th command restarts nginx server.
     
  19. EckyBrazzz

    EckyBrazzz Active Member

    391
    73
    28
    Mar 28, 2018
    Brazil
    Ratings:
    +143
    Local Time:
    9:36 AM
    1.17.x
    10.3.x
    haha, in that case I have to create a 100 domains. So better to edit the existing file to reflex that we have the domain, but that it's under constutruction. I only don't know where the file is located.
     
  20. eva2000

    eva2000 Administrator Staff Member

    40,276
    8,926
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +13,746
    Local Time:
    10:36 PM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    which file ? default IP welcome/nginx index.html ? that is located at /usr/local/nginx/html/index.html see config files overview at Centmin Mod Configuration Files - CentminMod.com LEMP Nginx web stack for CentOS and Getting Started Guide summary sentence. And well the index.html page itself mentions where it is located too ;)

    index.html page
     
    • Informative Informative x 1
..