Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Traefik Systemd Example with letsencrypt
# /etc/traefik/conf.d/blog.example.com.toml
[frontends.blog]
backend = "blog"
passHostHeader = true
entrypoints = ["https", "http"]
priority = 100
[frontends.blog.ratelimit]
extractorfunc = "client.ip"
[frontends.blog.ratelimit.rateset.rateset1]
period = "10s"
average = 100
burst = 200
[frontends.blog.routes.default]
rule = "Host:blog.example.com"
[backends.blog.LoadBalancer]
method = "wrr"
[backends.blog.servers.localhost]
url = "http://192.168.24.101"
weight = 1
# /lib/systemd/system/traefik.service
[Unit]
Description=Traefik Reverse Proxy
After=network.target
[Service]
User=root
Group=root
Environment="CF_API_EMAIL=john@example.com"
Environment="CF_API_KEY=ba1f2511fc30423bdbb183fe33f3dd0f"
ExecStart=/usr/local/bin/traefik -c /etc/traefik/traefik.toml
ExecReload=/bin/kill -USR1 $MAINPID
Restart=always
CPUShares=256
MemoryLimit=512M
RestartSec=5
[Install]
WantedBy=multi-user.target
# /etc/traefik/traefik.toml
# Accepted values, in order of severity: "DEBUG", "INFO", "WARN", "ERROR", "FATAL", "PANIC"
logLevel = "WARN"
MaxIdleConnsPerHost = 200
[traefikLog]
filePath = "/var/log/traefik/traefik.log"
format = "json"
[accessLog]
filePath = "/var/log/traefik/access.log"
format = "json"
[acme]
email = "john@example.com"
storage = "/etc/traefik/acme.json"
entryPoint = "https"
[acme.dnsChallenge]
provider = "cloudflare"
delayBeforeCheck = 0
[[acme.domains]]
main = "*.example.com"
sans = ["example.com"]
# [metrics]
# [metrics.influxdb]
# address = "http://user:pass@metrics.example.com:8086"
# protocol = "http"
# pushinterval = "10s"
# database = "pradam"
# username = "pradam"
# password = "pradam"
[entryPoints]
# default entrypoint
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
permanent = true
# SSL entrypoint
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
InsecureSkipVerify = true
# API/Dashboard entrypoint
[entryPoints.traefik]
address = ":8000"
[file]
directory = "/etc/traefik/conf.d/"
watch = true
[api]
entryPoint = "traefik"
dashboard = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment