Learn about Centmin Mod LEMP Stack today
Become a Member

Nginx My nginx is down

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Umit, Feb 22, 2018.

  1. eva2000

    eva2000 Administrator Staff Member

    44,425
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    6:13 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    no you should deal with autoprotect bypass and restore original in vhost .. autoprotect denys /src
     
  2. Umit

    Umit Member

    39
    5
    8
    Nov 15, 2016
    Ratings:
    +5
    Local Time:
    11:13 PM
    so i am commenting these lines in autoconf file:
    Code (Text):
    location /src/ {
      location ~ ^/src/(.+/)?(.+)\.(js)$ { allow all; expires 30d; }
      location ~ ^/src/(.+/)?(.+)\.(css)$ { allow all; expires 30d; }
      location ~ ^/src/(.+/)?(.+)\.(gif|jpe?g|png|webp|eot|svg|ttf|woff|woff)$ { allow all; expires 30d; }
      location ~ ^/src/(.+/)?(.+)\.(php|cgi|pl|php3|php4|php5|php6|phtml|shtml)$ { allow 127.0.0.1; deny all; }
    }
    
     
  3. eva2000

    eva2000 Administrator Staff Member

    44,425
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    6:13 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    no commenting out won't work as cronjob auto re-populates it as it scans your vhost directories at set interval.. proper way to exclude is by creating an empty .autoprotect-bypass file in /src directory and then re-running cron script /usr/local/src/centminmod/tools/autoprotect.sh
    But just updated 123.09beta01's tools/autoprotect.sh with exclusion for xenforo /src so update 123.09beta01 code
    Code (Text):
    cmupdate
    /usr/local/src/centminmod/tools/autoprotect.sh
    

    then check updated contents in /usr/local/nginx/conf/autoprotect/domain.com/autoprotect-domain.com.conf
     
  4. Umit

    Umit Member

    39
    5
    8
    Nov 15, 2016
    Ratings:
    +5
    Local Time:
    11:13 PM
    hmm, the update will auto fix?
    i updated the centmin 123.09beta01
    then
    /usr/local/src/centminmod/tools/autoprotect.sh

    Code (Text):
    generated nginx include file [same]: /usr/local/nginx/conf/autoprotect/deluxefxapp.com/autoprotect-deluxefxapp.com.conf
    
    generated nginx include file [same]: /usr/local/nginx/conf/autoprotect/demodomain.com/autoprotect-demodomain.com.conf
    
    generated nginx include file [diff]: /usr/local/nginx/conf/autoprotect/iamtravelr.com/autoprotect-iamtravelr.com.conf
    
    generated nginx include file [same]: /usr/local/nginx/conf/autoprotect/izkiz.net/autoprotect-izkiz.net.conf
    
    generated nginx include file [same]: /usr/local/nginx/conf/autoprotect/kusadasi.biz/autoprotect-kusadasi.biz.conf
    
    generated nginx include file [same]: /usr/local/nginx/conf/autoprotect/pictuts.com/autoprotect-pictuts.com.conf
    
    
    autoprotect.sh run completed skipped nginx restart...
    
    
    Restarting nginx (via systemctl):  Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
    
                                                              [FAILED]
    
    [00:24][root@server.pictuts.com centminmod]# 
    
     
  5. Umit

    Umit Member

    39
    5
    8
    Nov 15, 2016
    Ratings:
    +5
    Local Time:
    11:13 PM
    OK, i manually created an empty ".autoprotect-bypass" file on my xf's src folder and run
    /usr/local/src/centminmod/tools/autoprotect.sh

    and it looks good now :)
     
  6. eva2000

    eva2000 Administrator Staff Member

    44,425
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    6:13 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    yup that's it.. create .autoprotect-bypass file in directories you want tools/autoprotect.sh to skip auto creating rules for and then run /usr/local/src/centminmod/tools/autoprotect.sh regenerate all the autoprotect include files for each nginx vhost.
     
  7. Umit

    Umit Member

    39
    5
    8
    Nov 15, 2016
    Ratings:
    +5
    Local Time:
    11:13 PM
    Eva, thank you very much. I love centminmod. It is super fast. Switching to centminmod was one of the best idea that I ever had. Yes, I am experiencing some difficulties time to time, but it is OK, I will learn more.

    But, why a single mistake, like on this example, caused whole nginx to be down? which also means all of the websites that host. How can i prevent things like this in the future?
     
  8. eva2000

    eva2000 Administrator Staff Member

    44,425
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    6:13 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    You're lucky running out of disk space can potentially cause irreversible data corruption so you're lucky with simple nginx and mysql downtime so came out relatively well :)

    It's why sizing your server's disk capacity is important. I usually size it so my web site + mysql database total size then multiple it by 20x to 40x so if 5GB size data, then server needs 100GB to 200GB minimum free disk space excluding system disk occupied space. Why that large as I usually setup site and database backups to run at least 2 or 3 times a day so every 8 to 12 hours and keep at least 10-30 days of backups which also get offloaded to Amazon S3 storage. Also whenever I do major version updates, I always make a copy of live files and databases and set it aside and do test upgrades on the copied version of files and databases first to test if everything works - leaving live site files and database untouched. All this takes up disk space hence why I size like I do.

    Centmin Mod also has a disk alert cronjob that runs daily but the email notification isn't linked to any email. You can link it by editing the /etc/cron.daily/diskalert script's EMAIL field. I suggest you sign up for pushover.net for push alert email address and download to your mobile the pushover app for alerts via push notification rather than email as emails may not be that reliable.
    Code (Text):
    # Set admin email so that you can get email.
    EMAIL=''
    

    Default threshold for alerts is at 80% full
    Code (Text):
    # set alert level 90% is default
    DISKSPACE_ALERTPERCENTAGE='80'
    
     
  9. eva2000

    eva2000 Administrator Staff Member

    44,425
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    6:13 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
  10. Umit

    Umit Member

    39
    5
    8
    Nov 15, 2016
    Ratings:
    +5
    Local Time:
    11:13 PM
    installed, got pushover too, subscribed my device and loving it.
    is there a way to filter ifd csf emails? i put the pushover email to the system and getting way too many pushovers.
     
  11. eva2000

    eva2000 Administrator Staff Member

    44,425
    10,144
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,693
    Local Time:
    6:13 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    don't use as system wide emails - only for for diskalert or non system wide emails. You can setup separate pushover.net email aliases too for separate emails but that doesn't help with floods of emails.