• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Input Create back-ups of Nginx configuration to determine changes

mr-wolf

Silver Pleskian
Plesk Guru
Sometimes our servers stop doing what we expect them to do.
Often this is due to some automatic update that changes a config.
Sometimes it's just Plesk reverting some custom changes.

I already have some scripts in place that checks the folder /etc/postfix or /etc/dovecot for changes and that helped me a lot when troubleshooting it.

Because the Nginx config is built from many .conf files it's better to take a different approach.
I'm using the command "nginx -T" that outputs the resulting config.
When that resulting config is different than the latest stored config it will create a new one.
Using the "diff" command on these files will quickly lead you to the answer why something is now different:

ln -s /usr/local/sbin/nginx_backup /etc/cron.hourly/
cat /usr/local/sbin/nginx_backup
Code:
#!/bin/bash

FOLDER=/etc/nginx
DATESTAMP=`date +%Y-%m-%d.%H-%M`
NEWBACKUP=${FOLDER}/nginx.conf.${DATESTAMP}
TMPDIR=`mktemp -t -d ${0//*\/}.XXXXXXXXXX`
LATESTBACKUP="`ls -1t --color=none ${FOLDER}/nginx.conf.* | grep '[0-9][0-9]\-[0-9][0-9]$' | head -n1`"

nginx -T 2>/dev/null >${TMPDIR}/current
if [ -z "${LATESTBACKUP}" ] ; then
  mv ${TMPDIR}/current ${NEWBACKUP}
elif ! diff ${TMPDIR}/current ${LATESTBACKUP} 2>&1 >/dev/null ; then
  echo "Nginx configuration has changed, new one stored in ${NEWBACKUP}"
  mv ${TMPDIR}/current ${NEWBACKUP}
fi
rm -r ${TMPDIR}
 
Back
Top