Skip to content

How to Securely Deploy SafeLine WAF Using Docker Compose

Install SafeLine WAF securely with Docker Compose. Skip curl | bash, audit the compose file, use strong secrets, and lock down the admin UI with firewall rules.

On this page
  1. Architecture & security principles
  2. Prerequisites
  3. Step 1: Securely install Docker (official repository method)
  4. For Ubuntu / Debian systems
  5. Step 2: Prepare a dedicated application workspace
  6. Step 3: Fetch and audit the SafeLine Docker Compose artifacts
  7. Step 4: Configure environment & cryptographic secrets
  8. Step 5: Validate and launch services
  9. Step 6: Verify service health & initial setup
  10. Step 7: Post-installation hardening & maintenance
  11. Troubleshooting
  12. Wrap-up

Here’s how I deploy SafeLine WAF with Docker Compose without the vendor’s curl | bash script.

I run homelab apps in containers (see Jellyfin on Alpine for a different stack), and SafeLine sits in front of them. My approach on a VPS: read the compose file, generate a real DB password, and keep the admin UI away from the world.

Following along from the channel? Email me at thelinuxitguy@gmail.com, but don’t send me your .env. Rotate secrets if you pasted them in chat.

Architecture & security principles

  1. No uninspected execution: nothing piped into bash.
  2. Package integrity: Docker comes from the official signed repo.
  3. Isolation: services run in Docker containers.
  4. Strong credentials: secrets are randomly generated.
  5. Network boundaries: the management UI stays behind a firewall or VPN.

Piping to bash is convenient, but it’s the same pattern malware uses. We’ll fetch compose.yaml, read it, then docker compose up.

Prerequisites

  • A Debian/Ubuntu server you control. On Fedora/RHEL, use Docker’s official repo for those distros. Don’t use the apt steps on Rocky.
  • Root or sudo. I use sudo docker compose instead of adding users to the docker group, so the engine socket isn’t a second root.
  • Ports: 9443 (management UI), plus 80/443 if this box handles public traffic. Don’t put 9443 on the internet.
  • openssl, curl, gpg, and a firewall (ufw in the examples).
  • Enough disk under /data/safeline for images, Postgres, and logs.

If another reverse proxy already uses 80/443 here, plan your bindings first. Two processes can’t own 443.

Step 1: Securely install Docker (official repository method)

Skip curl -sSL https://get.docker.com | bash and add Docker’s signed repository instead.

For Ubuntu / Debian systems

Terminal window
# Update local package indexes and install prerequisites
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
# Create directory for official keyrings
sudo install -m 0755 -d /etc/apt/keyrings
# Download Docker's official GPG key with standard TLS verification
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
# Add the authenticated Docker repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# Update and install Docker Engine and Compose plugin
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Verify Docker daemon status
sudo systemctl is-active docker

You should see active, and docker compose version should print a v2 version. If VERSION_CODENAME isn’t an Ubuntu release Docker supports, you’re on Debian. Swap the linux/ubuntu paths for linux/debian and use the Debian codename, per docs.docker.com.

Enable on boot:

Terminal window
sudo systemctl enable --now docker
sudo docker run --rm hello-world

If hello-world fails, fix registry access before SafeLine’s much larger pull.

Podman Compose might work, but SafeLine’s YAML is written for Docker, so I don’t use it on CoreOS. CoreOS stays on Podman Quadlets for DNS (AdGuard).

Step 2: Prepare a dedicated application workspace

Terminal window
# Create application root directory
sudo mkdir -p /data/safeline
# Make your user the owner of the folder
sudo chown -R $USER:root /data/safeline
# Set ownership to root with strict permissions
sudo chmod 750 /data/safeline
cd /data/safeline

/data/safeline is separate from /home and easy to snapshot. chmod 750 keeps other local users out of the compose file and .env. It’s fine to chown it to $USER:root and run compose as root.

Step 3: Fetch and audit the SafeLine Docker Compose artifacts

Terminal window
# Download the compose configuration using enforced TLS verification
sudo curl -fsSL "https://waf.chaitin.com/release/latest/compose.yaml" -o /data/safeline/compose.yaml
# Inspect the file contents for unexpected images, volumes, or network privileges
less /data/safeline/compose.yaml

Audit checklist during inspection:

  • Images come from trusted registries (e.g., chaitin/*).
  • Ports match the expected services (management 9443, web 80/443).
  • Host volumes point only to /data/safeline/.
  • Look for privileged: true, Docker socket mounts (/var/run/docker.sock), and network_mode: host. They aren’t automatically bad, but stop and read if you see the socket.

curl -fsSL fails on TLS errors instead of writing half a file. If the URL 404s, get the new path from the vendor’s docs and still less before up.

Keep a copy to diff later:

Terminal window
sudo cp /data/safeline/compose.yaml /data/safeline/compose.yaml.$(date +%F)

Step 4: Configure environment & cryptographic secrets

Generate a random PostgreSQL password. Never use a default.

Terminal window
# Navigate to deployment directory
cd /data/safeline
# Generate a 32-character high-entropy secret for PostgreSQL
POSTGRES_SECURE_PASS=$(openssl rand -hex 16)
# Create the environment configuration file with secure permissions
sudo touch .env
sudo chmod 600 .env
# Populate .env configuration
sudo tee .env > /dev/null <<EOF
SAFELINE_DIR=/data/safeline
IMAGE_TAG=latest
MGT_PORT=9443
POSTGRES_PASSWORD=${POSTGRES_SECURE_PASS}
SUBNET_PREFIX=172.22.222
IMAGE_PREFIX=chaitin
ARCH_SUFFIX=
RELEASE=
REGION=-g
MGT_PROXY=0
EOF

The tee heredoc expands POSTGRES_SECURE_PASS in your shell. If that variable is empty, Postgres starts with an empty password. sudo cat /data/safeline/.env should show mode 600, and this should show a long hex string:

Terminal window
sudo grep POSTGRES_PASSWORD /data/safeline/.env

On a VPS you care about, swap IMAGE_TAG=latest for a pinned tag once you have a known-good deploy. SUBNET_PREFIX can’t collide with another Docker network or your LAN (172.22.222.0/24 style). If docker compose up complains about overlapping pools, pick another prefix.

If docker compose config errors on unknown variables, the vendor changed the .env keys. Check the comments in the YAML. Don’t invent keys.

Step 5: Validate and launch services

Terminal window
cd /data/safeline
# Verify environment variable substitution and syntax
sudo docker compose config
# Pull container images over HTTPS with signature verification
sudo docker compose pull
# Launch SafeLine in detached mode
sudo docker compose up -d

config prints the YAML with your password filled in, so don’t paste it into a ticket. If it shows the sample’s default password, your .env wasn’t read (--env-file / working directory). Always cd /data/safeline first. The pull can take a while.

Step 6: Verify service health & initial setup

Terminal window
# Monitor container status
sudo docker compose ps
# View initialization logs to ensure DB setup and service startup succeed without errors
sudo docker compose logs -f --tail=50

ps should show management, postgres, and related services Up. If postgres restart-loops, the password changed after the volume was created. Editing .env won’t fix it. Restore from backup, or wipe it only if you accept losing your WAF config.

Open the management console at: https://<YOUR-SERVER-IP>:9443

Expect a self-signed cert warning. Don’t click through it on a public IP. Use an SSH tunnel or VPN:

Terminal window
ssh -L 9443:127.0.0.1:9443 user@your-server

Then open https://127.0.0.1:9443 locally, and use the firewall rules below so 9443 isn’t open to the world.

Step 7: Post-installation hardening & maintenance

  1. Firewall rules (ufw / iptables):
    Only allow port 9443 from trusted admin IPs or a VPN (e.g., Tailscale / WireGuard).
Terminal window
sudo ufw allow from <YOUR_ADMIN_IP> to any port 9443 proto tcp
sudo ufw deny 9443/tcp
sudo ufw allow 22/tcp
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable
sudo ufw status

Replace <YOUR_ADMIN_IP>. With Tailscale, allow the tailnet prefix instead of your WAN IP (it changes). Order matters in ufw: a deny 9443 rule can block your allow depending on numbering. Check ufw status numbered and test from a non-admin IP.

If this host doesn’t serve public traffic on 80/443, don’t allow those ports.

  1. Obtain initial admin credentials:
Terminal window
sudo docker exec -it safeline-mgt resetadmin

Check sudo docker compose ps for the real container name. If resetadmin doesn’t exist in your image tag, use the vendor’s current reset docs. Don’t guess SQL against Postgres. Change the admin password after your first login.

  1. Backup strategy:
    Back up /data/safeline/ regularly (.env, database volumes, and SSL certificates). Stop compose before snapshotting /data/safeline for a consistent Postgres copy, or use pg_dump inside the DB container if you know the schema. Test a restore on a spare VM.

  2. Updating SafeLine securely:

Terminal window
cd /data/safeline
sudo cp compose.yaml compose.yaml.bak
sudo curl -fsSL "https://waf.chaitin.com/release/latest/compose.yaml" -o compose.yaml
diff -u compose.yaml.bak compose.yaml
sudo docker compose pull
sudo docker compose up -d

Read the diff. That’s the whole point of skipping curl | bash.

Troubleshooting

  • docker compose: command not found: you have classic docker-compose or nothing. This guide uses the v2 plugin (docker compose).
  • Permission denied on docker.sock: use sudo, or newgrp docker after adding your user to the group. The docker group is root-equivalent.
  • Can’t reach 9443: firewall, wrong MGT_PORT, or compose binds to 127.0.0.1 only. Check sudo ss -tulpn | grep 9443.
  • Let’s Encrypt / public site behind the WAF: only point DNS here once the WAF owns 80/443, not a leftover nginx.
  • Resource usage: a WAF plus Postgres isn’t a Pi Zero project. If compose ps is healthy but the site times out, check CPU and disk.

Wrap-up

Keep 9443 off the public internet, and remember a WAF doesn’t replace patching your apps or running nftables/ufw.

Best regards,

The Linux IT Guy