This is my personal note list for preparing a root server. The list is not complete and may contain errors.
Network setup
- Install OS as usual or use image from Control Panel
Network setup
SSH
VIM
Enable unattended upgrades
sudo apt-get install unattended-upgrades
sudo dpkg-reconfigure unattended-upgrades
Docker
- Install docker-ce here
- Install docker-compose
sudo apt-get install docker-compose-plugin
Install docker-compose here
Install docker-compose command completion here
- add username to docker group (source)
sudo usermod -aG docker $USER
Logrotate for Docker
Docker Compose aliases
Docker after dist upgrade
fail2ban
[traefik]
enabled = true
filter = traefik
logpath = /var/lib/docker/containers//-json.log
banaction = docker-action
maxretry = 3
findtime = 900
bantime = 86400
[wplogin]
enabled = true
filter = wplogin
logpath = /var/lib/docker/containers//-json.log
banaction = docker-action
maxretry = 3
findtime = 900
bantime = 86400
[unifi]
enabled = true
filter = unifi
logpath = /var/lib/docker/containers//-json.log
banaction = docker-action
maxretry = 3
bantime = 86400
findtime = 900
* Creat filter for traefik /etc/fail2ban/filter.d/traefik.conf
[Definition]
failregex = ^{"log":"<HOST> - \S+ [.*] \"(GET|POST|HEAD) .+\" 401 .+$
ignoreregex =
* Create filter for wplogin /etc/fail2ban/filter.d/wplogin.conf
[Definition]
failregex = ^{"log":"<HOST> -.POST.wp-login.php.*
ignoreregex =
* Create filter for unifi /etc/fail2ban/filter.d/unifi.conf
[Definition]
failregex = ^{"log":"<HOST> - \S+ [.*] \"POST \/api\/login.+\" 400 .+$
* Create action /etc/fail2ban/action.d/docker-action.conf
Unlike the out-of-the-box action, "actionban" and "actionunban" do not affect the INPUT chain, but the docker FORWARD chain "DOCKER".
[Definition]
actionstart = iptables -N f2b-docker
iptables -A f2b-docker -j RETURN
iptables -I FORWARD -p tcp -j f2b-docker
actionstop = iptables -D FORWARD -p tcp -j f2b-docker
iptables -F f2b-docker
iptables -X f2b-docker
actioncheck = iptables -n -L FORWARD | grep -q 'f2b-docker[ \t]'
actionban = iptables -I f2b-docker -s <ip> -j DROP
actionunban = iptables -D f2b-docker -s <ip> -j DROP
[via]https://www.the-lazy-dev.com/en/install-fail2ban-with-docker/[/via]