我正在使用 Docker-compose 和 Traefik 和 Let'sencrypt 在生产中测试cookiecutter-django 。我正在尝试将其配置为使用 Django 站点与 2 个域(mydomain1.com 和 mydomain2.com)一起使用。
如何配置 Traefik 以便将流量转发到必要的域?
这是我的 traefik.toml
logLevel = "INFO"
defaultEntryPoints = ["http", "https"]
# Entrypoints, http and https
[entryPoints]
# http should be redirected to https
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
entryPoint = "https"
# https is the default
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
# Enable ACME (Let's Encrypt): automatic SSL
[acme]
# Email address used for registration
email = "mail@mydomain1.com"
storage = "/etc/traefik/acme/acme.json"
entryPoint = "https"
onDemand = false
OnHostRule = true
# Use a HTTP-01 acme challenge rather than TLS-SNI-01 challenge
[acme.httpChallenge]
entryPoint = "http"
[file]
[backends]
[backends.django]
[backends.django.servers.server1]
url = "http://django:5000"
[frontends]
[frontends.django]
backend = "django"
passHostHeader = true
[frontends.django.headers]
HostsProxyHeaders = ['X-CSRFToken']
[frontends.django.routes.dr1]
rule = "Host:mydomain1.com"
现在所有域都通过 ssl 工作,但我只能看到 mydomain1.com,而 mydomain2.com 显示 ERR_TOO_MANY_REDIRECTS。