我已经苦苦挣扎了大约2个月,试图弄清traefik的网址重写和重定向的工作原理。
这是我的要求:
mysite.localhost
-> https://www.mysite.localhost
https://mysite.localhost
-> https://www.mysite.localhost
http://mysite.localhost:443
-> https://www.mysite.localhost
我已经设法使前两个用例工作正常,但是我正在努力寻找第三个用例的解决方案。这似乎是来自爬虫的奇怪请求。
当前,该请求将导致页面显示以下乱码:�
。我只想像其他域名一样重定向到主域名。
traefik.toml
<...snip...>
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.https]
address = ":443"
compress = true
[entryPoints.https.redirect]
regex = "^https://mysite.localhost(.*)"
replacement = "https://www.mysite.localhost$1"
permanent = true
<...snip...>
docker-compose.yml
<...snip...>
labels:
traefik.enable: "true"
traefik.backend: "webapp"
traefik.port: "8000"
traefik.webapp.frontend.headers.SSLRedirect: "true"
traefik.webapp.frontend.headers.SSLHost: "www.mysite.localhost"
traefik.webapp.frontend.headers.SSLForceHost: "true"
traefik.webapp.frontend.rule: "Host:www.mysite.localhost,mysite.localhost"
<...snip...>