返回顶部
T

Traefik

Avoid common Traefik mistakes — router priority, TLS configuration, Docker labels syntax, and middleware ordering.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.0
安全检测
已通过
931
下载量
2
收藏
概述
安装方式
版本历史

Traefik

## Router Basics - Router must have `rule` AND `service` — missing either = not working - Rule priority: longer rules win by default — explicit `priority` to override - `Host()` is case-insensitive — `Host(\`example.com\`)` matches Example.com - Multiple hosts: `Host(\`a.com\`) || Host(\`b.com\`)` — OR logic ## Docker Labels Syntax - Labels on container, not compose service level — `deploy.labels` for Swarm - Backticks for rules in Docker Compose — `Host(\`example.com\`)` with escaping - Enable per-container: `traefik.enable=true` — if `exposedByDefault=false` - Service name auto-generated from container — or set explicitly with `traefik.http.services.myservice.loadbalancer.server.port=80` ## TLS and Certificates - EntryPoint `websecure` needs TLS config — otherwise plain HTTP on 443 - Let's Encrypt: `certificatesResolvers.myresolver.acme.email` required — registration fails without - HTTP challenge needs port 80 open — DNS challenge for wildcard or closed 80 - `tls=true` on router activates TLS — `tls.certresolver=myresolver` for auto-cert - Staging ACME for testing — `caServer` to staging URL, avoids rate limits ## EntryPoints - Define in static config — `--entrypoints.web.address=:80` - Redirect HTTP to HTTPS at entrypoint level — cleaner than per-router middleware - Router binds to entrypoint with `entryPoints=web,websecure` — comma-separated list ## Middlewares - Chain order matters — first middleware wraps all following - Middleware defined once, used by many routers — `middlewares=auth,compress` - Common: `stripPrefix`, `redirectScheme`, `basicAuth`, `rateLimit` - BasicAuth: use `htpasswd` format — escape `$` in Docker Compose with `$$` ## Service Configuration - `loadbalancer.server.port` when container exposes multiple — Traefik can't guess - Health check: `healthcheck.path=/health` — removes unhealthy from rotation - Sticky sessions: `loadbalancer.sticky.cookie.name=srv_id` — for stateful apps ## Common Mistakes - Router without entryPoint — defaults may not be what you expect - Forgetting `traefik.docker.network` with multiple networks — Traefik picks wrong one - ACME storage not persisted — certificates regenerated, hits rate limit - Dashboard exposed without auth — `api.insecure=true` is dangerous in production - PathPrefix without StripPrefix — backend receives full path, may 404 - Services on different ports — each needs explicit port label ## File Provider - `watch=true` for hot reload — otherwise restart Traefik on changes - Can coexist with Docker provider — useful for external services - Define routers, services, middlewares in YAML — same concepts as labels ## Debugging - `--log.level=DEBUG` for troubleshooting — verbose but helpful - Dashboard shows routers, services, middlewares — verify configuration - `--api.insecure=true` for local dev only — secure with auth in production

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 traefik-1776328447 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 traefik-1776328447 技能

通过命令行安装

skillhub install traefik-1776328447

下载 Zip 包

⬇ 下载 Traefik v1.0.0

文件大小: 2.08 KB | 发布时间: 2026-4-17 16:22

v1.0.0 最新 2026-4-17 16:22
Initial release

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部