Skip to content

Instantly share code, notes, and snippets.

@opentaq
Last active November 2, 2025 17:41
Show Gist options
  • Select an option

  • Save opentaq/2ce85108bee528700477c6db89610968 to your computer and use it in GitHub Desktop.

Select an option

Save opentaq/2ce85108bee528700477c6db89610968 to your computer and use it in GitHub Desktop.
Mailserver Installation

Fail2Ban

sudo install fail2ban

UFW

sudo install ufw

UFW Settings

sudu ufw default deny incomoing

sudo ufw default allow outgoins

sudo ufw allow 22,25,80,110,143,443,465,587,993,995,4190/tcp

sudo ufw enable

Mailserver

Install curl and git

sudo apt install curl git -y

Install Docker

su

curl -sSL https://get.docker.com/ | CHANNEL=stable sh

systemctl enable --now docker

Install Docker Compose

curl -sSL https://github.com/docker/compose/releases/download/v$(curl -Ls https://www.servercow.de/docker-compose/latest)/docker-compose-$(uname -s)-$(uname -m) > /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

Install the mail server

su

cd /opt

git clone https://github.com/mailcow/mailcow-dockerized

cd mailcow-dockerized

./generate_config.sh

Start the mail server

docker-compose pull

docker-compose up -d

@mercurial-moon
Copy link

Great tutorial, thanks. Why do you install fail2ban when the mailcow installation already provides a fail2ban instance?

mailcow provided fail2ban protects the container interfaces i.e protection for docker, it won't protect the server interfaces .. eg. ssh.. installing fail2ban on the server protects those.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment