Benjamin Crozat “Heard about Sevalla? They let you deploy PHP apps with ease.” Claim $50 →

danielpetrica.com

Laravel and Traefik dynamic config for easy multi-domain setups →

I just read a short guide by Daniel Petrica on using Laravel with Traefik to handle many domains without hand-editing configs.

The idea is simple:

  • Let Laravel build Traefik rules on the fly.
  • Point Traefik’s HTTP provider at a secure Laravel endpoint.
  • Serve YAML instead of JSON for smooth reloads.

Traefik provider sample:

# traefik.yml
providers:
  http:
    endpoint: "https://admin.example.com/internal/traefik_config"
    pollInterval: "15s"
    headers:
      customRequestHeaders:
        X-Traefik-Passphrase: "yoursecrettoken"

Laravel response sample using Symfony YAML:

use Symfony\Component\Yaml\Yaml;

return response(
    content: Yaml::dump($config, 10),
    status: 200,
    headers: ['Content-Type' => 'text/yaml']
);

Why I like it:

  • No giant static file to babysit.
  • Add or remove domains in your app and Traefik follows after the next poll.
  • Works great with Docker and a single service.

If you run Laravel behind Traefik and juggle many domains, this is a clean, low-friction pattern. Daniel’s write-up is short and practical, and it gave me a few ideas for my next deploy.

Read more on danielpetrica.com →


Did you like this article? Then, keep learning:

Help me reach more people by sharing this article on social media!

0 comments

Guest

Markdown is supported.

Hey, you need to sign in with your GitHub account to comment. Get started →

Great tools for developers

Search for posts and links

Try to type something…