• Debian 11 is approaching its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.80 will be the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

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