• The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

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