- Git
- Docker
- Docker Compose
git clone git@github.com:bubelov/traefik-letsencrypt-compose.gitnano traefik-letsencrypt-compose/.envDOMAIN=example.local
EMAIL=admin@example.local
TRAEFIK_USER=admin
TRAEFIK_PASSWORD_HASH=$2y$10$zi5n43jq9S63gBqSJwHTH.nCai2vB0SW/ABPGg2jSGmJBVRo0A.ni # adminIf you're curious about HTTP basic auth and how it can be used with Traefik, you can read the full post. Here is the excerpt and it assumes you already installed htpasswd:
htpasswd -nBC 10 admin
New password:
Re-type new password:
admin:$2y$10$zi5n43jq9S63gBqSJwHTH.nCai2vB0SW/ABPGg2jSGmJBVRo0A.niThe resulting format is quite straighforward: username:hashedPassword. The username doesn't have to be admin, feel free to change it.
You can paste the username into the TRAEFIK_USER environment variable. The other part, hashedPassword, should be assigned to TRAEFIK_PASSWORD_HASH. Now you have your own username:password pair.
cd ~/traefik-letsencrypt-compose
docker-compose up -dsudo nano /etc/hosts127.0.0.1 example.local
127.0.0.1 traefik.example.local
Let's say you have a domain example.com and it's DNS records point to your production server. Just repeat the local deployment steps but don't forget to set the DOMAIN environment variable with your real domain. In case of example.com, your .env file should have the following line:
DOMAIN=example.comYou should also uncomment the following lines inside docker-compose.yml in order to use Let’s Encrypt to generate a trusted certificate instead of self-signed one that we used for local deployment:
#traefik.http.routers.traefik-https.tls.certresolver=letsencrypt