What is Traefik?

And how is it different to NGINX?

I’ve come across Traefik in a number of questions on Stack Overflow recently. I regularly use NGINX as a reverse proxy and sometimes find it to be a little obscure. Having an alternative would be helpful.

Traefik and NGINX are both popular open-source solutions which can act as

  • reverse proxy
  • load balancer and
  • web server.

They serve slightly different purposes and are designed with different priorities in mind.

Traefik and NGINX: Comparison

Here’s a simple comparison:

Traefik

Traffic was first released on 6 July 2016, although there were numerous alpha and beta releases prior to that.

  • Dynamic Configuration — Traefik features dynamic configuration and can automatically detect changes in your environment (like services being added or removed) without needing manual updates or restarts.
  • Automatic HTTPS — Traefik simplifies the process of securing your applications with HTTPS by automatically obtaining and renewing SSL certificates from Let’s Encrypt.
  • Developer-Friendly — Traefik is easy to deploy. It provides a web UI for monitoring and has extensive documentation.

NGINX

NGINX was first released in October 2004, so it’s been around for at least a decade longer than Traefik. This may account for it being so pervasive, although its dominance might wane with the rise of Traefik.

  • Static Configuration — NGINX relies on a static configuration file that requires manual updates and a reload or restart of the service to apply changes.
  • Performance and Efficiency — NGINX is renowned for its high performance and efficiency, particularly in serving static content and handling a large number of concurrent connections with a low memory footprint.
  • Flexibility and Control — NGINX offers detailed configuration options that allow for fine-tuned optimisation of its behavior.

Traefik and NGINX: Key Differences

There are a few key differences which might be helpful in choosing which product is the right fit for a specific project:

  • Configuration Model — The most significant difference between Traefik and NGINX is their approach to configuration. Traefik is designed to automatically adapt to changes in your environment, making it highly suitable for dynamic, containerised environments. NGINX uses a static configuration that requires manual updates, which might be inconvenient in environments with frequent scaling of services.
  • Use Case and Focus — NGINX is a versatile tool and is application agnostic. Traefik is specifically aimed at microservices architectures, with a focus on automation and simplicity in dynamic environments.
  • SSL/TLS Management — Traefik provides automatic SSL/TLS certificate management, a significant advantage for securing applications quickly and easily. NGINX can also be configured to use SSL/TLS certificates but this needs to be done manually (although it’s fairly simple using the certbot tool).

Conclusion

The choice between Traefik and NGINX depends on specific project needs and environment. Traefik is particularly well-suited for dynamic, containerised environments where automatic configuration and service discovery are required. NGINX is a good choice for a wide range of applications, including serving as a web server, especially when precise control over configuration and optimisation is needed.

See the next post for a simple Traefik setup.