Using Coolify for subdomain direct redirect without a app resource

Coolify's dynamic proxy configuration lets you redirect subdomains to external URLs without creating full resources. Using a simple YAML file with Traefik configuration, you can set up SSL-enabled redirects directly through Coolify's interface.

Using Coolify for subdomain direct redirect without a app resource
Photo by Nick Fewings / Unsplash

You should know by now that I'm a pretty big fan of Coolify. I use it to manage all of my applications.

One of the things I love the most about Coolify is how it automagically handles DNS for you. Write where you want your app to be hosted and boom, it'll set it up for you. Dont, and it will generate one for you. You can read more about it here.

Deciding where your app will be available is as easy as writing it down

Today, I faced a new use case for the first time : I had a Claude artifact that was hosted somewhere already, but wanted one of my subdomains to redirect to it.

I know I could do it directly via my registrar's DNS interface, but because all of my apps are handled via Coolify I wanted to keep it as such if possible.

The issue is, to access this domain configuration setting from Coolify, you have to create a resource (git repo, Dockerfile, . . . ).

Turns out there is another way : the dynamic proxy configuration.

My use case is as such : I want to have https://blogprocessor.lengrand.quest/ redirect to https://claude.ai/public/artifacts/b21d3e9c-b05f-4fe3-923e-63e1144cfff8. To do this :

  • Navigate to Servers > [YourServer] > Proxy > Dynamic Configuration in your Coolify dashboard.
The server proxy dynamic configuration page
  • Create a new YAML file (in my case claude.yaml) with the following structure:
http:
  routers:
    blogprocessor-redirect:
      rule: Host(`blogprocessor.lengrand.quest`)
      service: blogprocessor-redirect-service
      middlewares:
        - blogprocessor-redirect-middleware
      tls:
        certResolver: letsencrypt
  middlewares:
    blogprocessor-redirect-middleware:
      redirectRegex:
        regex: '^https://blogprocessor\.lengrand\.quest/?(.*)'
        replacement: 'https://claude.ai/public/artifacts/b21d3e9c-b05f-4fe3-923e-63e1144cfff8'
        permanent: true
  services:
    blogprocessor-redirect-service:
      loadBalancer:
        servers:
          - url: 'http://127.0.0.1:9999'

(Note : I am using the traefik proxy here, but you can use Caddy too)

The actual content of the configuration is pretty simple :

  • A Middleware that describes what kind of redirection I want
  • A router to be able to handle tls
  • A (dummy) service because somehow the router requires a service and a middleware

I have tried to get rid of the dummy service but couldn't find a way to get the TLS handling without it. The good news however is that I can keep using that file as I create more Claude artifacts without having to create much more configuration.

If you find a way, please let me know!

I want to thank Cinzya, one of the moderators of the Coolify server for pointing me in the right direction, she's been super helpful!