New Webserver Setup
Over the past few weeks, I have upgraded my webserver that hosts all of my projects. This was mostly due to the recent CVE's with PHP and nginx.
My old webserver was a FreeBSD server on DigitalOcean that ran Apache directly on the host. I had fail2ban, a logrotate, webalizer, and ipfw firewall. This served me well for many years, but my patching cadence was not regular. pkg updates were a little daunting forme, as in the past I've had mixed success.
The server was very old when the security alerts happened in October, so I felt it was best to build a new server. I really like FreeBSD but DigitalOcean no longer supports it as an official image. I could have created a custom image for it, but decided the support burden down the road might be too great. Configuring FTP, the firewall, and the webserver packages was super easy. But, in the end I decided to try Rocky Linux.
One benefit of Rocky over FreeBSD is that it supports Docker, so I decided to take full advantage of it. The new server uses an nginx container as a reverse proxy, and a php-apache container for my webhosting. The proxy basically checks the hostname and routes to apache, which also has its own virtualhost construct. In the future, I envision deploying other standalone applications in Docker and reverse proxying to them, something that would have been difficult in the FreeBSD server.
The way that I organized the server is that each compose stack runs in its on user directory, by a nologin user. This was the way we deployed apps before docker, which lets them all run in a user directory sandbox. I don't know how relevant that is for docker, but it seems like with the host bind mounts I use, it might improve security.
Another big change is that I used Ansible to build the server. This will hopefully encourage me to patch it more. It means that to rebuild it is simply an ansible playbook run. I also have a playbook to update the nginx and apache configs, as well as a playbook to patch the server by rebuilding the containers and issuing a dnf upgrade and reboot.
I still like to update my websites on apache with FTP, so I setup an SFTP user on the system so I can update this site and others.
Overall it took a little work to get this set up, but I'm happy with the end result. I patched the server today in response to some new CVE's that dropped, and it was very easy.