this docker-compose file
version: '3'
services:
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
networks:
- web
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /root/traefik.toml:/traefik.toml
- /root/acme.json:/acme.json
- /root/traefik_dynamic.toml:/traefik_dynamic.toml
- /root/config.yml:/config.yml:ro
networks:
web:
external: true
this is my config yaml #192.168.52.239
traefik.yaml
Global configuration
global:
checkNewVersion: true
Entry points
entryPoints:
http:
address: ":80"
https:
address: ":443"
Let's Encrypt configuration
certificatesResolvers:
myresolver:
acme:
email: your-email@example.com
storage: acme.json
httpChallenge:
entryPoint: http
HTTP Routers
http:
routers:
my-router:
rule: "Host(sample.kalai.live
)"
entryPoints:
- https
service: my-service
tls:
certResolver: myresolver
HTTP Services
http:
services:
my-service:
loadBalancer:
servers:
- url: "192.168.52.239:80"
passHostHeader: true
this is traefik,toml file[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.web.http.redirections.entryPoint]
to = "websecure"
scheme = "https"
[entryPoints.websecure]
address = ":443"
[api]
dashboard = true
[certificatesResolvers.lets-encrypt.acme]
email = "kalaiselvan467@gmail.com"
storage = "acme.json"
[certificatesResolvers.lets-encrypt.acme.tlsChallenge]
[providers.docker]
watch = true
network = "web"
[providers.file]
filename = "traefik_dynamic.toml"
[global]
checkNewVersion = true
Log settings
[log]
level = "INFO"
[http]
[http.routers]
# Define a connection between requests and services
[http.routers.to-whoami]
rule = "Host(sample.kalai.live
) && PathPrefix(/
)"
# If the rule matches, applies the middleware
middlewares = ["test-user"]
# If the rule matches, forward to the whoami service (declared below)
service = "whoami"
[http.middlewares]
# Define an authentication mechanism
[http.middlewares.test-user.basicAuth]
users = ["test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/"]
[http.services]
# Define how to reach an existing service on our infrastructure
[http.services.whoami.loadBalancer]
[[http.services.whoami.loadBalancer.servers]]
url = "http://192.168.52.109"
this is my traefik_dynamic.toml
[http.middlewares.simpleAuth.basicAuth]
users = [
"admin:$apr1$6jGEtLR8$sErgHnVt5Kz9O/vjXCgi3."
]
[http.routers.api]
rule = "Host(traefik.kalai.live
)"
entrypoints = ["websecure"]
middlewares = ["simpleAuth"]
service = "api@internal"
[http.routers.api.tls]
certResolver = "lets-encrypt"