Last active
August 9, 2025 13:35
-
-
Save horacioibrahim/074d56345b91fcd9fcd9c8e6429b8b9f to your computer and use it in GitHub Desktop.
setup-ufw.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# setup-docker.sh — Ubuntu (DigitalOcean) | |
# 1. Instalar UFW | |
sudo apt install -y ufw | |
# 2. Permitir as portas que você vai precisar | |
sudo ufw allow 22/tcp # SSH | |
sudo ufw allow 80/tcp # HTTP | |
sudo ufw allow 443/tcp # HTTPS | |
# 3. Ajustar política padrão | |
sudo ufw default deny incoming | |
sudo ufw default allow outgoing | |
# 4. Configurar Docker para respeitar UFW | |
sudo mkdir -p /etc/docker | |
cat <<EOF | sudo tee /etc/docker/daemon.json | |
{ | |
"iptables": false | |
} | |
EOF | |
sudo systemctl restart docker | |
# 5. Ativar UFW | |
sudo ufw enable | |
# 6. Verificar | |
sudo ufw status verbose | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment