Wiki source code of Traefik

Version 1.1 by chrisby on 2023/10/27 19:27

Show last authors
1 Traefik is usually included in the other [[Software Stacks|doc:Software Stacks.WebHome]], but this page is for special use cases.
2
3 ### Redirect from HTTP to HTTPS
4
5 ```yaml
6 traefik:
7 image: "traefik:latest"
8 container_name: "traefik"
9 restart: unless-stopped
10 command:
11 - "--api.insecure=true"
12 - "--providers.docker=true"
13 - "--providers.docker.exposedbydefault=false"
14 - "--entrypoints.websecure.address=:443"
15 - "--certificatesresolvers.myresolver.acme.tlschallenge=true"
16 - "--certificatesresolvers.myresolver.acme.email=<EMAIL>"
17 - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
18 # This enables redirect from HTTP to HTTPS
19 - "--entrypoints.web.address=:80"
20 - "--entrypoints.web.http.redirections.entryPoint.to=websecure"
21 - "--entrypoints.web.http.redirections.entryPoint.scheme=https"
22 - "--entrypoints.web.http.redirections.entryPoint.permanent=true"
23 # Uncomment for test mode. This allows detailed logging and creation of a fake certificate.
24 # - "--log.level=DEBUG"
25 # - "--certificatesresolvers.myresolver.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
26 ports:
27 - "80:80"
28 - "443:443"
29 volumes:
30 - "./data/traefik/letsencrypt:/letsencrypt"
31 - "/var/run/docker.sock:/var/run/docker.sock:ro"
32 ```