Secure Your Server

Use these layers to protect any Linux server that runs web applications. Each layer has general steps first, then extra steps for servers that run Coolify or are connected to Coolify. Read the Security Model to learn which parts Coolify protects.

Do not lock yourself out

Keep your current SSH session open while you change SSH or firewall settings. Test each change from a second terminal. If SSH stops working, use the server console in your hosting provider dashboard.

1. Harden the server

General

  • Use SSH keys only. Add PasswordAuthentication no to /etc/ssh/sshd_config, then run sudo sshd -t && sudo systemctl restart ssh.
  • Install security updates automatically with sudo apt install unattended-upgrades.
  • Do not use a shared user. Give each person their own SSH key, and remove keys that you do not use.

With Coolify

2. Close public ports

General

Use the firewall in your hosting provider dashboard. Do not use UFW by itself: Docker-published ports go around UFW rules.

PortRule
22Allow only from your IP address, or close it after step 3
80, 443Allow, or allow only from Cloudflare after step 4
Database portsClose, unless a trusted client must connect directly
All other portsClose

With Coolify

PortRule
22Also allow the Coolify server, so that it can connect to remote servers
8000, 6001, 6002Close after the dashboard works through a domain or Tailscale

See Firewall for all ports that Coolify uses.

3. Use Tailscale for private access

General

Tailscale makes SSH and admin panels available only to devices in your tailnet.

  1. Install Tailscale on each server and on your computer:

    curl -fsSL https://tailscale.com/install.sh | sh
    sudo tailscale up
    tailscale ip -4
  2. Test SSH with the Tailscale IP address: ssh root@100.x.y.z.

  3. Remove port 22 from the provider firewall.

With Coolify

  1. In Coolify, open each remote server, set IP address or domain to its Tailscale IP address, and click Revalidate connection.
  2. Open the dashboard at http://100.x.y.z:8000.
  3. Remove ports 8000, 6001, and 6002 from the provider firewall.
Limits
  • Coolify Cloud cannot join your tailnet. Keep port 22 open to the Coolify Cloud IPv4 and IPv6 addresses.
  • Git providers cannot send webhooks to a dashboard that is only in your tailnet. For automatic deployments, keep the dashboard on a public domain and protect it with the WAF rule in step 5.

4. Put Cloudflare in front of your applications

General

Use one of these setups:

  • Cloudflare proxy: set your DNS records to Proxied, use a Cloudflare Origin Certificate, and allow ports 80 and 443 only from the Cloudflare IP ranges.
  • Cloudflare Tunnel: run cloudflared on the server. You do not need inbound web ports.

With Coolify

5. Add Cloudflare WAF rules

General

In the Cloudflare dashboard, select your domain and go to Security > WAF. The available rules depend on your Cloudflare plan. Test new rules with Managed Challenge before you use Block.

  1. Turn on the Managed rules for your plan.

  2. Block admin panels for other IP addresses. Action: Block.

    (http.host eq "admin.example.com" and not ip.src in {203.0.113.10})
  3. Optional: block countries that you do not serve.

    (not ip.src.country in {"DE" "FR"})

With Coolify

  1. Block the dashboard for other IP addresses, but allow webhooks. Action: Block.

    (http.host eq "coolify.example.com"
      and not ip.src in {203.0.113.10}
      and not starts_with(http.request.uri.path, "/webhooks/"))
  2. Add a rate limiting rule for login attempts. Action: Block above your request limit.

    (http.host eq "coolify.example.com"
      and http.request.uri.path eq "/login"
      and http.request.method eq "POST")
  3. Do not use a country block on the dashboard domain, because webhooks come from many countries.

Confirm the setup works

General

From a computer outside your tailnet, run nmap -Pn -p 22,80,443 <server-public-ip>. Closed ports must show filtered or closed. Then make sure that each application opens through HTTPS.

With Coolify

Add ports 6001, 6002, and 8000 to the nmap command. Then make sure that the dashboard opens, each server validates, and a Git push starts a deployment.

On this page