Traefik 整域名重定向 TOML 配置示例
基于我们的基础 Traefik 配置 简单的 Traefik docker-compose 部署:使用 Let’s Encrypt Cloudflare DNS-01、TLS-ALPN-01 与 HTTP-01 挑战,下面是一份完整的 TOML 配置,用于将 my.olddomain.com 重定向到 my.newdomain.com,其中 my.olddomain.com 使用带有通配符(*.olddomain.com)的 Let’s Encrypt 证书以及 DNS-01 挑战来提供服务。
myredirect.toml
[http.routers]
[http.routers.RedictMyOlddomain]
rule = "Host(`my.olddomain.com`)"
entryPoints = ["websecure"]
middlewares = ["RedictMyOlddomain"]
service = "noop"
[http.routers.RedictMyOlddomain.tls]
certResolver = "cloudflare-ec384"
[[http.routers.RedictMyOlddomain.tls.domains]]
main = "olddomain.com"
sans = ["*.olddomain.com"]
[http.middlewares]
[http.middlewares.RedictMyOlddomain.redirectRegex]
regex = "https?://my\\.olddomain\\.com/(.*)"
replacement = "https://my.newdomain.com/$1"
permanent = true
[http.services]
[http.services.noop.loadBalancer]
[[http.services.noop.loadBalancer.servers]]
url = "http://127.0.0.1" # 虚拟目标,用于让 Traefik 正常工作Check out similar posts by category:
Traefik
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow