Switching from nginx proxy manager to Traefik turned out to be a game-changer for this infrastructure setup, here's why.
Why the Switch
The primary reason for migrating to Traefik is scalability. Unlike nginx proxy manager, which requires manual configuration through a web UI, Traefik's configuration lives directly in your Docker Compose files. This means when you migrate to a new server or scale your infrastructure, there's no need to recreate configurations manually, everything is already defined in code.
The Beauty of Labels
With Traefik, you simply add labels to your Docker services, and the proxy configuration happens automatically. Here's an example of how a service gets configured:
labels:
- "traefik.enable=true"
- "traefik.docker.network=proxy"
- "traefik.http.services.humfurie.loadbalancer.server.port=80"
- "traefik.http.routers.humfurie.rule=Host(`humfurie.org`)"
- "traefik.http.routers.humfurie.entrypoints=websecure"
- "traefik.http.routers.humfurie.tls=true"
- "traefik.http.routers.humfurie.tls.certresolver=letsencrypt"
- "traefik.http.routers.humfurie.middlewares=fallback-errors@file"
- "traefik.http.routers.humfurie-www.rule=Host(`www.humfurie.org`)"
- "traefik.http.routers.humfurie-www.entrypoints=websecure"
- "traefik.http.routers.humfurie-www.tls=true"
- "traefik.http.routers.humfurie-www.tls.certresolver=letsencrypt"
- "traefik.http.routers.humfurie-www.middlewares=fallback-errors@file"
Key Benefits
Infrastructure as Code: all your proxy configuration is version-controlled alongside your services.
Automatic Discovery: Traefik automatically detects new services and configures routing without manual intervention.
Easy Migration: moving to a new server just means bringing your Docker Compose files along.
Let's Encrypt Integration: SSL certificate management is built-in and automatic.
Conclusion
If you're managing multiple services and planning to scale, Traefik's label-based configuration approach is far more maintainable than traditional proxy managers. The initial learning curve is worth the long-term benefits of having your entire infrastructure defined as code.