Want more timely Centmin Mod News Updates?
Become a Member

Nginx Conf.d went missing

Discussion in 'Install & Upgrades or Pre-Install Questions' started by gabel, Nov 21, 2017.

  1. gabel

    gabel New Member

    8
    3
    3
    Jan 7, 2016
    Ratings:
    +4
    Local Time:
    1:28 AM
    1.9.9
    MariaDB 10
    Please fill in any relevant information that applies to you:
    • CentOS Version: CentOS 7 64bit
    • Centmin Mod Version Installed: 123.09beta01
    • Nginx Version Installed: 1.13.6
    • PHP Version Installed: 5.6.30
    • MariaDB MySQL Version Installed:10.1.21
    • When was last time updated Centmin Mod code base ? : today
    • Persistent Config:
      NGINX_FLV=y
      NGINX_MP4=y
      NGINX_STREAM=y
      NGINX_RTMP=y
      LETSENCRYPT_DETECT=y
      NGINX_IPV=y



      Hey,

      Tried to update to nginx 1.13.6 and seems that /usr/local/nginx/conf/conf.d/ is gone

      cd /usr/local/nginx/conf/conf.d/
      -bash: cd: /usr/local/nginx/conf/conf.d/: No such file or directory

      Tried reverting back to 1.13.4 but no dice , even though it says nginx installed perfectly .
    https://www.screencast.com/t/NeoVaDu5W8wZ

    Now seems that the sites are down too and don't know what to do . Any clues?
    Thanks
     
  2. eva2000

    eva2000 Administrator Staff Member

    31,021
    6,924
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,430
    Local Time:
    11:28 AM
    Nginx 1.13.x
    MariaDB 5.5
    Well need alot of troubleshooting here and questions and answers.

    Troubleshooting


    1. What was previous Nginx version you were on ?
    2. Are you running as full root user when you do upgrades or running as a sudo user you created ?
    As full root user in SSH, what's output for this command below - wrap output in CODE tags
    Code (Text):
    history | egrep -w 'conf.d|rm' | grep '.11.17'
    

    and output for
    Code (Text):
    ls -lah /usr/local/nginx/conf/conf.d/
    

    For posting code you might want to use CODE tags for code How to use forum BBCODE code tags :)

    To troubleshoot, you need to check the the nginx upgrade log at /root/centminlogs and instructions under Sharing logs and errors heading for using Pastebin.com or Gists to share a sanitised version of the contents of the nginx_upgrade.log log. You can see full details at How to troubleshoot Centmin Mod initial install issues

    also what's output of
    Code (Text):
    nginx -t

    when you run centmin.sh menu option 4 there's a nginx upgrade log timestamped at /root/centminlogs

    if you type this command it lists all logs in date ascending order so latest log at bottom
    Code (Text):
    ls -lArt /root/centminlogs

    so copy the entire contents of latest nginx_upgrade log to gist.github.com or pastebin.com

    you can use grep to filter the logs, i.e. look for nginx_upgrade in log name
    Code (Text):
    ls -lahrt /root/centminlogs/ | grep nginx_upgrade
    -rw-r--r--  1 root root 3.2M Oct 11 15:55 centminmod_1.2.3-eva2000.09.001_111016-155345_nginx_upgrade.log
    -rw-r--r--  1 root root 672K Oct 11 22:06 centminmod_1.2.3-eva2000.09.001_111016-220515_nginx_upgrade.log

    So the last nginx upgrade log was named centminmod_1.2.3-eva2000.09.001_111016-220515_nginx_upgrade.log and located at /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-220515_nginx_upgrade.log

    then use cat command to output the contents of that log

    clear your ssh window buffer/screen and type
    Code (Text):
    cat /root/centminlogs/centminmod_1.2.3-eva2000.09.001_111016-220515_nginx_upgrade.log

    then select and copy and paste output to pastebin.com or gist.github.com file to share. If your SSH client's scroll buffer isn't large enough using cat might not output the entire log file contents, so you may need to download the log and use local text editor to open and copy and paste.

    so only need content of one specific log, in this case most recent nginx_upgrade.log log

    Restoring Nginx Auto Backups



    Each time you upgrade Nginx an auto backup of nginx conf files and ssl directories is generated. See http://centminmod.com/nginx.html#autobackup and http://centminmod.com/configfiles.html
    So if you accidentally deleted your Nginx vhost files at /usr/local/nginx/conf/conf.d/ and/or SSL files at /usr/local/nginx/conf/ssl/ you can restore a previous copy from /usr/local/nginxbackup which has 2 directories
    1. /usr/local/nginxbackup/confbackup which is backup for everything within /usr/local/nginx/conf including subdirectories like /usr/local/nginx/conf/conf.d/
    2. /usr/local/nginxbackup/nginxdirbackup which is backup for everything within /usr/local/nginx/ including subdirectories
    Code (Text):
    ls -lah /usr/local/nginxbackup
    total 32K
    drwxr-xr-x.   4 root root 4.0K Apr  4  2017 .
    drwxr-xr-x.  22 root root 4.0K Sep  9 05:27 ..
    drwxr-xr-x. 212 root root  12K Nov 20 00:25 confbackup
    drwxr-xr-x. 212 root root  12K Nov 20 00:25 nginxdirbackup
    

    So for instance for backup dated 310817 = 31 August, 2017 at /usr/local/nginxbackup/confbackup/conf_310817-005457/conf.d/ would have Nginx vhost config files which were backed up from /usr/local/nginx/conf/conf.d/
    Code (Text):
    ls -lah /usr/local/nginxbackup/confbackup/conf_310817-005457/conf.d/
    
    -rw-r--r--  1 root root 1.1K Aug 30 18:55 demodomain.com.conf
    -rw-r--r--  1 root root 2.0K Aug 30 18:55 domain1.com.conf
    -rw-r--r--  1 root root 3.3K Aug 30 18:55 domain1.com.ssl.conf
    -rw-r--r--  1 root root  846 Aug 30 18:55 ssl.conf
    -rw-r--r--  1 root root 2.6K Aug 30 18:55 virtual.conf
    

    and /usr/local/nginxbackup/confbackup/conf_310817-005457/ssl would contain the nginx ssl certificate files backed up from /usr/local/nginx/conf/ssl

    So contents of /usr/local/nginxbackup/confbackup/conf_310817-005457/ssl
    Code (Text):
    ls -lah /usr/local/nginxbackup/confbackup/conf_310817-005457/ssl
    
    drwxr-xr-x. 2 root root 4.0K Apr  4  2017 domain1.com
    

    has /usr/local/nginxbackup/confbackup/conf_310817-005457/ssl/domain1.com backups for /usr/local/nginx/conf/ssl/domain1.com
    Code (Text):
    ls -lah /usr/local/nginxbackup/confbackup/conf_310817-005457/ssl/domain1.com
    total 40K
    drwxr-xr-x. 2 root root 4.0K Apr  4  2017 .
    drwxr-xr-x. 6 root root 4.0K Jun 23 11:24 ..
    -rw-r--r--. 1 root root  424 Apr  4  2017 dhparam.pem
    -rw-r--r--. 1 root root  952 Apr  4  2017 domain1.com-backup.csr
    -rw-r--r--. 1 root root 1.7K Apr  4  2017 domain1.com-backup.key
    -rw-r--r--. 1 root root 1.1K Apr  4  2017 domain1.com.crt
    -rw-r--r--. 1 root root  952 Apr  4  2017 domain1.com.csr
    -rw-r--r--. 1 root root 1.7K Apr  4  2017 domain1.com.key
    -rw-r--r--. 1 root root   45 Apr  4  2017 hpkp-info-primary-pin.txt
    -rw-r--r--. 1 root root   45 Apr  4  2017 hpkp-info-secondary-pin.txt
    
     
  3. gabel

    gabel New Member

    8
    3
    3
    Jan 7, 2016
    Ratings:
    +4
    Local Time:
    1:28 AM
    1.9.9
    MariaDB 10
    1. Had 1.13.4 before , tried reverting but no dice .

    2. Yup full root , no sudo.

    3. history | egrep -w 'conf.d|rm' | grep '.11.17' output .
    Code:
       14  [21.11.17] 00:35:16   rm -rf *
       94  [21.11.17] 00:35:16   rm -rf videos
       98  [21.11.17] 00:35:16   nano /usr/local/nginx/conf/conf.d/cdn.pornoreino.com.conf
     1363  [20.11.17] 21:20:20   rm -rf /root/centminlogs/acmetool.sh-debug-log-201117-201724.log
     1375  [20.11.17] 21:27:07   rm -rf /root/centminlogs/acmetool.sh-debug-log-201117-201724.log
     1388  [20.11.17] 21:29:38   cd /usr/local/nginx/conf/conf.d/
     1420  [20.11.17] 21:36:52   cd /usr/local/nginx/conf/conf.d/
     1436  [20.11.17] 21:39:33   rm -rf .well-known
     1442  [20.11.17] 21:45:53   cd /usr/local/nginx/conf/conf.d/
     1451  [20.11.17] 21:49:51   rm -rf /root/centminlogs/acmetool.sh-debug-log-201117-214410.log
     1461  [20.11.17] 21:55:49   rm -rf /root/centminlogs/acmetool.sh-debug-log-201117-215418.log
     1465  [20.11.17] 21:58:05   rm -rf /root/centminlogs/acmetool.sh-debug-log-201117-215418.log
     1469  [20.11.17] 21:59:46   rm -rf /root/centminlogs/acmetool.sh-debug-log-201117-215418.log
     1480  [20.11.17] 22:01:32   rm -rf /root/centminlogs/acmetool.sh-debug-log-201117-215418.log
     1491  [20.11.17] 22:04:55   rm -rf cdn.pornoreino.com
     1494  [20.11.17] 22:09:36   cd /usr/local/nginx/conf/conf.d/
     1501  [20.11.17] 22:11:53   rm -rf cd /usr/local/nginx/conf/conf.d/
     1503  [20.11.17] 22:11:58   cd /usr/local/nginx/conf/conf.d/
     1506  [20.11.17] 22:12:06   cd /usr/local/nginx/conf/conf.d/
     1510  [20.11.17] 22:12:23   nano /usr/local/nginx/conf/conf.d/cdn.pornoreino.com.conf
     1524  [20.11.17] 22:23:56   cdcd /usr/local/nginx/conf/conf.d/
     1525  [20.11.17] 22:23:57   cd /usr/local/nginx/conf/conf.d/
     1557  [20.11.17] 23:30:15   cd /usr/local/nginx/conf/conf.d/
     1561  [20.11.17] 23:30:38   locate conf.d
     1565  [20.11.17] 23:31:40   nano /usr/local/nginxbackup/confbackup/conf_100117-135040/conf.d/cdn.pornoreino.com.conf
     1576  [20.11.17] 23:25:53   cd /usr/local/nginx/conf/conf.d/
     1582  [21.11.17] 00:06:37   cd /usr/local/nginx/conf/conf.d/
     1609  [21.11.17] 00:22:00   rm -rf /svr-setup/pcre-*
     1610  [21.11.17] 00:22:00   rm -rf /svr-setup/libressl-*
     1616  [21.11.17] 00:35:20   cd /usr/local/nginx/conf/conf.d/
     1624  [21.11.17] 01:49:28   history | egrep -w 'conf.d|rm' | grep '.11.17'
    
    4. ls -lah /usr/local/nginx/conf/conf.d/ output :

    Code:
    ls -lah /usr/local/nginx/conf/conf.d/
    ls: cannot access /usr/local/nginx/conf/conf.d/: No such file or directory
    
    5. Upgrade log https://gist.github.com/anonymous/f2801e020632320cac5da16f253243c7
     
  4. eva2000

    eva2000 Administrator Staff Member

    31,021
    6,924
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,430
    Local Time:
    11:28 AM
    Nginx 1.13.x
    MariaDB 5.5
    there's the problem you ran this command on Nov 20th at 10:11 pm
    Code (Text):
     1501  [20.11.17] 22:11:53   rm -rf cd /usr/local/nginx/conf/conf.d/
    

    which means rm -rf = delete both directory cd and directory /usr/local/nginx/conf/conf.d/ :eek:

    so find a backup within /usr/local/nginxbackup/confbackup/ which is most recent

    list directories in ascending date order so most recent directory is listed last from command
    Code (Text):
    ls -lahrt /usr/local/nginxbackup/confbackup/
    

    and restore it's contents to /usr/local/nginx/conf/conf.d/

    i.e. if most recent is at /usr/local/nginxbackup/confbackup/conf_100117-135040/conf.d, then change into directory, copy all files to nginx vhost directory and then list contents of that directory and restart nginx
    Code (Text):
    cd /usr/local/nginxbackup/confbackup/conf_100117-135040/conf.d
    \cp -af * /usr/local/nginx/conf/conf.d/
    ls -lah /usr/local/nginx/conf/conf.d/
    ngxrestart
    
     
  5. gabel

    gabel New Member

    8
    3
    3
    Jan 7, 2016
    Ratings:
    +4
    Local Time:
    1:28 AM
    1.9.9
    MariaDB 10
    (bad word) sideways and call me molly , i didn'\t even see that rm -rf , don't even know how that ended up there as i manually type everything. Was trying to renew a ssl certificate and think that's how rm -rf ended up in front of that no clue .Now i just feel stupid , doing sensitive stuff at 2 am not good lol . Oh man now back to that ssl renewal.

    Thank you again @eva2000 great job here and keep it up .
     
    • Like Like x 1
  6. eva2000

    eva2000 Administrator Staff Member

    31,021
    6,924
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,430
    Local Time:
    11:28 AM
    Nginx 1.13.x
    MariaDB 5.5
    Yeah it's why i created that auto nginx conf directory backup routine which runs everytime you run centmin.sh menu option 4 to recompile/upgrade/downgrade nginx versions :)