Reverse Proxy Comparison: Traefik vs. Caddy vs. Nginx (Docker)

7 Comments
Modified: 01.05.2023

Are you looking at which reverse proxy for docker is the best for you? In this post, I will compare Traefik, Caddy, and Nginx (nginx-proxy) based on my personal experience! In the end, you will know their strengths and weaknesses and hopefully manage to reach a conclusion on which to choose!

Introduction

When it comes to setting up a reverse proxy on docker, there are several options available. In this blog post, we’ll take a closer look at three reverse proxies: Traefik, Caddy, and Nginx-proxy. We’ll discuss the benefits and drawbacks of each container and evaluate them based on the initial setup effort, container setup effort, and how well it works

Server icon

VPS Hosting Course

Learn everything you need to know about servers and hosting your own applications!

Disclaimer: This is based on my personal experience using them for my side projects and thus includes my personal opinion.

Initial setup effort: ⭐ = high effort, ⭐⭐⭐ = low effort

Proxy setup effort: ⭐ = high effort, ⭐⭐⭐ = low effort

Overall simplicity: ⭐ = complex, ⭐⭐⭐ = simple

Need help or want to share feedback? Join my discord community!

Traefik – The cloud-native reverse proxy for docker

Traefik is a powerful and versatile reverse proxy container that is designed for cloud-native applications. It supports dynamic configuration and automatic SSL certificate generation, making it a flexible and powerful option for advanced users. However, the configuration of the containers based on labels is something I do not like much. You have to remember the syntax, and it is not super intuitive. When it is set up it works well, but this is a lot of upfront effort compared to the other two options. On the other hand, Traefik is much more powerful and, for example, allows you to create multiple containers of one type and automatically configures a load balancer for all of them!

The labels you have to set on a container for a simple reverse proxy look like this:

KOFI Logo

If this guide is helpful to you and you like what I do, please support me with a coffee!

labels:
  - "traefik.enable=true"
  - "traefik.http.routers.frontend.rule=Host(`<domain.tld>`)"

If you like Traefik, have a closer look at this post here!

Initial setup effort: ⭐
Proxy setup effort: ⭐
Functionality: ⭐

Caddy – The simple reverse proxy for your docker containers

Caddy is a simple and user-friendly reverse proxy container that is easy to set up and configure. Its configuration file uses a simple syntax, and it supports multiple protocols. Caddy also includes automatic SSL certificate generation through its integration with Let’s Encrypt. The only downside is that caddy does not automatically configure the reverse proxy for new containers automatically as the other two options do. But, because of the simple syntax inside the Caddyfile, it is still a low effort. The configuration looks like this:

<domain.tld> {
    reverse_proxy http://frontend:8000
}

If you like Caddy have a closer look at this post here!

Initial setup effort: ⭐⭐⭐
Proxy setup effort: ⭐⭐(⭐) – using something like: caddy-docker-proxy (more on that below)
Overall simplicity: ⭐⭐⭐

Caddy docker proxy works similarly to nginx-proxy by automatically creating the Caddyfile based on some container configurations. Instead of using environment variables, it uses labels, similar to traefik. In my opinion, Caddy does not need the proxy setup because the syntax inside the Caddyfile is super simple and short. But give both a try and see what works best for you (I am not a huge fan of labels, although they are way simpler than traefiks!).

Nginx-proxy – The versatile option

Nginx-proxy is a straightforward reverse proxy that supports automatic configuration generation through the use of environment variables. It automatically creates proxy configurations based on the VIRTUAL_HOST environment variable, making it easy to set up for basic reverse proxy needs. Together with its Let’s Encrypt companion, it also automatically generates SSL certificates!

These options work really well for a basic reverse proxy. As soon as you need something more you have to create a custom configuration. The good thing is that it uses nginx, so you have access to all the powerful features of nginx while still having a simple setup for most containers. For a basic configuration with SSL you have to set the following two environment variables:

environment:
  VIRTUAL_HOST: <domain.tld>
  LETSENCRYPT_HOST: <domain.tld>

If you like nginx-proxy, have a closer look at this post here!

Initial setup effort: ⭐⭐
Proxy setup effort: ⭐⭐⭐
Overall simplicity: ⭐⭐

Conclusion

In this post, we had a look at three different reverse proxies for docker. If you do not care about the amount of effort you get a really powerful and flexible option with Traefik. If you prefer a simple and user-friendly option for basic reverse proxy needs, Caddy might be a good fit. And if you’re looking for something in between the two maybe Nginx-proxy might be the way to go.

I personally use nginx-proxy because it works really well, and I am using it for a couple of years now. If I would start now or if I would want some change, I would definitely go for Caddy because, in my opinion, it had a really cool developer experience, and I love the focus on simplicity!

Update: By now I completly switched to caddy and I love it!

Which one do you like the most?

As a little revision, here are all of the ratings in one table:

TraefikCaddyNginx-proxy
Initial setup effort⭐⭐⭐⭐⭐
Proxy setup effort⭐⭐(⭐)⭐⭐⭐
Overall simplicity⭐⭐⭐⭐⭐⭐

In case you have any questions, feel free to ask in the comments or join my discord. Additionally, if you are interested in learning about all my new posts, consider subscribing to my newsletter!

Discussion (7)

Add Comment

Your email address will not be published. Required fields are marked *