Nginx Upgrade Gotchas
Looking at my server configuration and saw that my Nginx version was 1.18.x which was release approximately April 2020 and that corresponds to probably when I was last editing my nginx reverse proxy start of Covid 19 restrictions etc.
Time to upgrade to latest and greatest, what could go wrong? (Always make a backup before you do any system maintenance, I didn't this time and it was a pain) Turns out a lot, but it was good to get my memory refreshed on linuxy configuration incompatibilities.
Step 1 get Ubuntu to install latest Nginx
Normally I run the command sudo apt update
and I am done, but Nginx would not update because the listed package has not been update for a stable release. First steps are get apt command to register a maintained list item with means installing the package source in etc/apt/sources.list.d
echo "deb http://nginx.org/packages/mainline/ubuntu `lsb_release -cs` nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
Stole the above command from someone else's setup, but the idea is ask installation what is the debian distribution then go to nginx.org website and use the tee command to pipe and change the output to grab the proper configuration for going forward.
Add the signing keys
curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add -
Now you are set so you can do sudo apt update
. However this doesn't work because nginx appears as manual installation on my system so I had to force it through with this sudo apt install nginx
This ran through several prompts and completed the installation, but I noticed that there were some errors and unfortunately they appeared to be dealing with configurations.
Taking a step back and look over the configurations affected sudo grep -R root /etc/nginx/*
Step 2 Fix the configs
Nginx deprecated the sites-enabled, sites-available
folders process which I had setup and configured to load my special configurations for my site reverse proxies to as detailed here
In some package repositories, this folder is named sites-enabled, and configuration files are linked from a folder named site-available; this convention is deprecated.
Looking at my current setup I see that I symlinked the configuration files into those folders so I am going to symlink the configuration files again into the default config folder for Nginx etc/nginx/conf.d
Commands is
sudo ln -s /<ghost installation>/siliconheaven.info-ssl.conf .
Step3 Test
Restart or reload the Nginx configurations
- Restart -
sudo systemctl restart nginx
- Reload -
sudo systemctl reload nginx
Step 4 Access configurations work again
Although it wasn't as easy as this as I had to spend sometime remembering and looking up commands to determine the above corrective actions. Again make a backup of systems before you make transformative large changes like this.