将端口后缀添加到域中后,Traefik url重写和重定向不起作用

时间:2019-04-26 14:03:24

标签: docker docker-compose traefik

我已经苦苦挣扎了大约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...>

0 个答案:

没有答案