Deploying a Next.js application on Coolify should be a smooth experience, but we recently ran into an issue when changing the autogenerated domain to a custom one. Despite configuring the correct DNS records, we encountered a No server detected
error when trying to access the domain. The root cause? Coolify did not properly update Traefik’s container labels to reflect the new domain.
In this post, I’ll walk through our deployment process, the issue we faced, and the solution we found to fix it.
The Deployment Flow
Set up the project: We deployed our Next.js app on Coolify as usual.
Changed the domain: We updated the automatically generated domain to our desired custom domain.
Successful deployment: The Coolify dashboard showed that the deployment was successful.
Encountered an error: When accessing the custom domain, we got a “No server found” error, despite having the correct DNS records pointing to our server’s IP.
The Issue
Looking at the Traefik configuration, we found that the labels still referenced the autogenerated domain instead of our custom one. Here’s what the incorrect labels looked like:
traefik.enable=true
traefik.http.middlewares.gzip.compress=true
traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
traefik.http.routers.http-0-autogenerated.entryPoints=http
traefik.http.routers.http-0-autogenerated.middlewares=gzip
traefik.http.routers.http-0-autogenerated.rule=Host(`autogenerated.example.com`) && PathPrefix(`/`)
traefik.http.routers.http-0-autogenerated.service=http-0-autogenerated
traefik.http.services.http-0-autogenerated.loadbalancer.server.port=3000
Despite the DNS being configured correctly, Traefik was still expecting requests for the old autogenerated domain, leading to a failed resolution for our custom domain.
The Solution
To resolve the issue, we manually updated the Traefik labels to reflect our custom domain. The correct configuration looked like this:
traefik.enable=true
traefik.http.middlewares.gzip.compress=true
traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https
traefik.http.routers.http-0-custom.entryPoints=http
traefik.http.routers.http-0-custom.middlewares=redirect-to-https
traefik.http.routers.http-0-custom.rule=Host(`customdomain.com`) && PathPrefix(`/`)
traefik.http.routers.http-0-custom.service=http-0-custom
traefik.http.routers.https-0-custom.entryPoints=https
traefik.http.routers.https-0-custom.middlewares=gzip
traefik.http.routers.https-0-custom.rule=Host(`customdomain.com`) && PathPrefix(`/`)
traefik.http.routers.https-0-custom.service=https-0-custom
traefik.http.routers.https-0-custom.tls.certresolver=letsencrypt
traefik.http.routers.https-0-custom.tls=true
traefik.http.services.http-0-custom.loadbalancer.server.port=3000
traefik.http.services.https-0-custom.loadbalancer.server.port=3000
What Changed?
Updated the Host rule: We replaced the old autogenerated domain with our custom domain (customdomain.com).
Added HTTPS routing: The original misconfiguration only handled HTTP, but proper HTTPS routing was necessary.
Ensured TLS settings were applied: We explicitly enabled TLS and Let’s Encrypt for SSL certificates.
Conclusion
Coolify’s automated domain changes didn’t properly propagate to Traefik’s labels, leading to a misconfiguration that prevented our custom domain from resolving correctly. By manually updating the Traefik labels, we were able to restore proper routing.
If you’re running into similar issues, double-check Traefik’s labels and make sure they match your intended domain settings. This can save you a lot of troubleshooting time!
Top comments (0)