Skip to content

Instantly share code, notes, and snippets.

@yoyosan
Last active August 28, 2022 10:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yoyosan/20e1d89425775e8627485f094d30c1ed to your computer and use it in GitHub Desktop.
Save yoyosan/20e1d89425775e8627485f094d30c1ed to your computer and use it in GitHub Desktop.
Setting up a secure Ubuntu 20.04 server

I'll enumerate below a suite of guides I've followed to setup a Ubuntu server:

Optional:

Notes:

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp -d mail.domain1.com,mail.domain2.com --cert-name mail.domain1.com --email you@example.com

Upgrade tasks

Commands to upgrade Nginx and the ModSecurity module:

sudo apt-mark unhold nginx
sudo apt upgrade nginx

# The install process will fail because your ModSecurity module version doesn't match with the new version of Nginx
# So, let's update ModSecurity to the latest nginx version

# check nginx version
nginx -v

cd /usr/local/src/nginx
sudo apt install dpkg-dev
# download nginx sources
apt source nginx

cd nginx-1.23.1/ # or the version previously queried
./configure --with-compat --add-dynamic-module=/usr/local/src/ModSecurity-nginx
make modules
sudo cp objs/ngx_http_modsecurity_module.so /usr/share/nginx/modules/

# resume upgrade process
sudo apt upgrade
sudo apt-mark hold nginx
apt-mark showhold
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment