You have to secure your websites with SSL!
How to setup Traefik v2 with automatic Let’s Encrypt certificate resolver
Today it is really important to have SSL encrypted websites. This guide will show how easy it is to have an automatic SSL resolver built into your traefik load balancer.
After I learned how to docker, the next thing I needed was a service to help me organize my websites. This is why I learned about traefik which is a:
Cloud-Native Networking Stack That Just Works
One important feature of traefik is the ability to create Let’s Encrypt SSL certificates automatically for every domain which is managed by traefik.
Then I started to research…
I tested several configurations and created my own traefik instances on my local machine until I came up with this docker-compose.yml:
This file contains several important sections:
- Two entry points
web
(Line 8) andwebsecure
(Line 9) which are used forhttp
andhttps
- Enabling docker (Line 10) but not publishing every container by default (Line 11)
- Activate API (with URL defined in labels) (Line 12)
- Certificate handling. Defining an info email (Line 13), set a storage
acme.json
(Line 14), activating TLS (Line 15) - Exposing port for HTTP (Line 17) and HTTPS (Line 18)
- Within the volumes section, the docker-socket will be mounted into
traefik
container (Line 20) and theacme.json
is mounted into the local filesystem (Line 21) - Enable
traefik
for this service (Line 23). This has to be done because no service is exported by default (see…