skip to content

coolify 5 min read

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!

Cool dude

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:

Terminal window
# Get your IPv4 address
curl -4 ifconfig.me
# Or check IPv6 if available
curl -6 ifconfig.me

Save this IP address - you’ll need it for DNS configuration.

Step 2: Add Your Domain to Cloudflare

  1. Log in to Cloudflare Dashboard
  2. Click “Add a Site”
  3. Enter your domain name and click “Add site”
  4. Select the Free plan and click “Continue”
  5. 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.com
brad.ns.cloudflare.com

Go 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):

FieldValue
TypeA
Name@
IPv4 address[Your server IP from Step 1]
Proxy statusProxied (orange cloud)
TTLAuto

For www subdomain (IPv4):

FieldValue
TypeA
Namewww
IPv4 address[Same server IP]
Proxy statusProxied
TTLAuto

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

  1. In Cloudflare menu, go to SSL/TLS → Overview
  2. Select Flexible mode
  3. Go to SSL/TLS → Edge Certificates
  4. 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 ModeWhen to UseSecurity Level
FlexibleBlogs, portfolios, informational sitesBasic
FullApps with sensitive dataHigh (Cloudflare to server encrypted)
Full (Strict)E-commerce, banking, medical dataMaximum (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:

Terminal window
netstat -plnt | grep :80

You 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-proxy
tcp6 0 0 :::80 :::* LISTEN xxxxx/docker-proxy

VPS Providers with Port Restrictions

Some VPS providers (like Mikrus, some shared hosting) block or restrict ports 80/443. If your provider blocks these ports:

  1. Check your provider’s documentation for available ports
  2. Use a reverse proxy (nginx/Caddy) to forward from an allowed port to Coolify
  3. 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

  1. Log in to your Coolify panel (e.g., http://your-server-ip:8000)
  2. Go to your application
  3. Click Configuration → Domains
  4. In the Domains field, enter:
    http://yourdomain.com,http://www.yourdomain.com
  1. 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
  2. Click Set Direction

  3. Click Save

  4. 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 work
  • https://www.yourdomain.com - should work or redirect
  • http://yourdomain.com - should redirect to HTTPS

You can also test from the command line:

Terminal window
curl -I https://yourdomain.com
Successful Borat

Troubleshooting

Error 404

Check Traefik logs:

Terminal window
docker logs coolify-proxy --tail 50 | grep yourdomain

If you see errors related to PathPrefix or empty Host(), make sure:

  • You entered the domain with http:// (not https://) 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 (not https://)

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

Filip Chrapek

Let's work together

What do you need?
Budget
When?

Prefer email? hi@philgood.dev