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.
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 noto/etc/ssh/sshd_config, then runsudo 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
- Set up the Coolify SSH key with the OpenSSH guide. To log in without root, see Non-root user.
- Use Server patching to see and install updates from the dashboard.
- On self-hosted Coolify, turn on 2FA or passkeys, and keep a backup in a different location.
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.
| Port | Rule |
|---|---|
22 | Allow only from your IP address, or close it after step 3 |
80, 443 | Allow, or allow only from Cloudflare after step 4 |
| Database ports | Close, unless a trusted client must connect directly |
| All other ports | Close |
With Coolify
| Port | Rule |
|---|---|
22 | Also allow the Coolify server, so that it can connect to remote servers |
8000, 6001, 6002 | Close 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.
-
Install Tailscale on each server and on your computer:
curl -fsSL https://tailscale.com/install.sh | sh sudo tailscale up tailscale ip -4 -
Test SSH with the Tailscale IP address:
ssh root@100.x.y.z. -
Remove port
22from the provider firewall.
With Coolify
- In Coolify, open each remote server, set IP address or domain to its Tailscale IP address, and click Revalidate connection.
- Open the dashboard at
http://100.x.y.z:8000. - Remove ports
8000,6001, and6002from the provider firewall.
- Coolify Cloud cannot join your tailnet. Keep port
22open 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
80and443only from the Cloudflare IP ranges. - Cloudflare Tunnel: run
cloudflaredon 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.
-
Turn on the Managed rules for your plan.
-
Block admin panels for other IP addresses. Action: Block.
(http.host eq "admin.example.com" and not ip.src in {203.0.113.10}) -
Optional: block countries that you do not serve.
(not ip.src.country in {"DE" "FR"})
With Coolify
-
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/")) -
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") -
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.
Load Balancing on Hetzner
Deploy scalable load-balanced applications on Hetzner Cloud with Coolify including TLS termination, health checks, database setup, and firewall configuration.
macOS using Colima Setup Guide
Install Coolify on macOS using a Colima virtual machine with Docker, covering VM creation, networking, and SSH configuration.
