How to set up a custom domain with SSL for Coolify using Cloudflare
Learn how to configure a custom domain for your Coolify applications using Cloudflare as a reverse proxy.
Hey you! Do you want to be cool?
Sure you do! Let’s set up a custom domain with your Coolify setup—I’ll show ya!
What You’ll Need
- A VPS server with Coolify installed (installation guide)
- A custom domain (from any registrar: Namecheap, GoDaddy, Cloudflare, etc.)
- A Cloudflare account (free)
- SSH access to your server
Why Cloudflare?
Cloudflare acts as a reverse proxy between your users and your server, providing:
- Free SSL certificates (automatic, no configuration needed)
- DDoS protection
- CDN caching for faster load times
- Global network with 300+ data centers
- Analytics and monitoring
All of this is available on their free plan!
Step 1: Check Your Server’s IP Address
SSH into your server and get your public IP address:
# Get your IPv4 addresscurl -4 ifconfig.me
# Or check IPv6 if availablecurl -6 ifconfig.meSave this IP address - you’ll need it for DNS configuration.
Step 2: Add Your Domain to Cloudflare
- Log in to Cloudflare Dashboard
- Click “Add a Site”
- Enter your domain name and click “Add site”
- Select the Free plan and click “Continue”
- Cloudflare will scan your existing DNS records
Step 3: Update Nameservers at Your Domain Registrar
Cloudflare will show you two nameservers, for example:
anna.ns.cloudflare.combrad.ns.cloudflare.comGo to your domain registrar’s control panel (Namecheap, GoDaddy, etc.) and change your nameservers to these Cloudflare nameservers.
Step 4: Configure DNS Records in Cloudflare
Go to DNS → Records in Cloudflare and add records for your domain.
Understanding A vs AAAA Records
- A record - Points domain to IPv4 address (e.g.,
95.217.144.47) - AAAA record - Points domain to IPv6 address (e.g.,
2001:db8::1)
Which should you use?
- If your VPS has only IPv4: Use A records only
- If your VPS has both IPv4 and IPv6: Add both A and AAAA records
- If your VPS has only IPv6 (rare): Use AAAA records only
Most VPS providers give you IPv4 by default. Check with curl -4 ifconfig.me (IPv4) and curl -6 ifconfig.me (IPv6).
For the root domain (IPv4):
| Field | Value |
|---|---|
| Type | A |
| Name | @ |
| IPv4 address | [Your server IP from Step 1] |
| Proxy status | Proxied (orange cloud) |
| TTL | Auto |
For www subdomain (IPv4):
| Field | Value |
|---|---|
| Type | A |
| Name | www |
| IPv4 address | [Same server IP] |
| Proxy status | Proxied |
| TTL | Auto |
If you have IPv6 (optional):
Repeat the above but use Type: AAAA and enter your IPv6 address instead.
For email (if you use a separate email server):
Keep your existing MX records unchanged and ensure they have Proxy status: DNS only (gray cloud).
Step 5: Configure SSL/TLS in Cloudflare
- In Cloudflare menu, go to SSL/TLS → Overview
- Select Flexible mode
- Go to SSL/TLS → Edge Certificates
- Enable:
- Always Use HTTPS
- Automatic HTTPS Rewrites
Understanding SSL Modes
Flexible (Recommended for getting started):
- User ↔ Cloudflare: HTTPS (encrypted)
- Cloudflare ↔ Your server: HTTP (unencrypted)
This is sufficient for most use cases (blogs, portfolios, informational sites).
| SSL Mode | When to Use | Security Level |
|---|---|---|
| Flexible | Blogs, portfolios, informational sites | Basic |
| Full | Apps with sensitive data | High (Cloudflare to server encrypted) |
| Full (Strict) | E-commerce, banking, medical data | Maximum (requires valid certificate) |
Step 6: Verify Coolify is Listening
Before configuring your domain, ensure Coolify’s Traefik proxy is running and listening on port 80:
netstat -plnt | grep :80You should see output showing that Docker is listening on port 80:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN xxxxx/docker-proxytcp6 0 0 :::80 :::* LISTEN xxxxx/docker-proxyVPS Providers with Port Restrictions
Some VPS providers (like Mikrus, some shared hosting) block or restrict ports 80/443. If your provider blocks these ports:
- Check your provider’s documentation for available ports
- Use a reverse proxy (nginx/Caddy) to forward from an allowed port to Coolify
- Or use Cloudflare Tunnel (formerly Argo Tunnel) which doesn’t require open ports
For detailed setup with port restrictions, check the Polish version of this guide or your provider’s documentation.
Step 7: Configure Domain in Coolify
- Log in to your Coolify panel (e.g.,
http://your-server-ip:8000) - Go to your application
- Click Configuration → Domains
- In the Domains field, enter:
http://yourdomain.com,http://www.yourdomain.com
-
In the Direction field, choose:
- “Redirect to non-www” - if you want to redirect www to the main domain
- “Allow www & non-www” - if you want to serve both versions
-
Click Set Direction
-
Click Save
-
At the top of the page, click Redeploy
Why http:// in Coolify?
This might seem counterintuitive, but it’s the correct configuration:
User → [HTTPS] → Cloudflare → [HTTP] → Your Server → Coolify- Users always see HTTPS (thanks to Cloudflare)
- Cloudflare connects to your server via HTTP (Flexible mode)
- Coolify must accept HTTP connections, hence
http://in the configuration
Step 8: Testing
Wait 2-5 minutes for the configuration to propagate, then test:
https://yourdomain.com- should workhttps://www.yourdomain.com- should work or redirecthttp://yourdomain.com- should redirect to HTTPS
You can also test from the command line:
curl -I https://yourdomain.com
Troubleshooting
Error 404
Check Traefik logs:
docker logs coolify-proxy --tail 50 | grep yourdomainIf you see errors related to PathPrefix or empty Host(), make sure:
- You entered the domain with
http://(nothttps://) in Coolify - You clicked Redeploy after saving changes
- You selected an option in Direction and clicked Set Direction
Too Many Redirects Loop
This indicates an SSL conflict. Check:
- Cloudflare SSL/TLS is set to Flexible (not Full)
- In Coolify you’re using
http://in domains (nothttps://)
Site Not Loading
- Wait for DNS propagation (up to 24 hours)
- Verify A records (and AAAA if using IPv6) are Proxied (orange cloud in Cloudflare)
- Clear browser cache or test in incognito mode
- Check if nameservers were changed:
dig NS yourdomain.com
Cloudflare Shows 502 Bad Gateway
- Check if Coolify is running:
docker ps | grep coolify - Check logs:
docker logs coolify-proxy --tail 100 - Ensure your application is running in Coolify
Connection Timeout
- Verify your firewall allows port 80 (required for Cloudflare Flexible mode)
- Check if your hosting provider blocks port 80 - some providers restrict standard HTTP/HTTPS ports
- Ensure Cloudflare proxy is enabled (orange cloud)
- If your provider blocks port 80, see “VPS Providers with Port Restrictions” in Step 6
Additional Resources
Summary
Congratulations! Your Coolify application is now accessible via your custom domain with a free SSL certificate from Cloudflare.
This configuration provides:
- Free SSL certificate
- Automatic HTTP → HTTPS redirect
- DDoS protection
- Global CDN
- Easy maintenance