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:
- Practical fixes for common Laravel errors complementing Laravel usage
- Troubleshoot common Laravel CSRF error to improve app stability
- Learn to add Alpine.js, enhancing Laravel frontend interaction
- Step-by-step tutorial for building ChatGPT plugins with Laravel
- Upgrade your Laravel projects confidently with this comprehensive guide
- Overall Laravel best practices to improve your development workflow
- Learn to create Single Page Applications easily with Livewire in Laravel
- Understand how to deploy Laravel apps on cloud effectively
- Guide to Laravel service container for cleaner dependency injection
- Learn effective use of Laravel's File facade for file management
0 comments