链接到网站的另一个链接不会重定向https

时间:2018-04-28 17:13:38

标签: traefik

使用以下配置,我的网址会自动重定向到https

enter image description here

但内容并不直接。

enter image description here

这是CoreOS上的当前配置:

在traefik.toml

[entryPoints]
    [entryPoints.http]
    address = ":80"
#      [entryPoints.http.redirect]
#      entryPoint = "https"
    [entryPoints.https]
    address = ":443"
      [entryPoints.https.tls]
        [[entryPoints.https.tls.certificates]]
        certFile = "/etc/traefik/ssl/ee.crt"
        keyFile = "/etc/traefik/ssl/private.key"

在docker-compose.yml

...
labels:
    - traefik.enabled=true
    - traefik.backend=oms_nginx
    - traefik.frontend.rule=Host:mydomain.com
    - traefik.http.redirect=https
    - traefik.frontend.redirect=https
    - traefik.http.frontend.entryPoints=http
    - traefik.http.frontend.redirect=https
    - traefik.https.frontend.entryPoints=https
    - traefik.frontend.headers.SSLRedirect=true
    - traefik.frontend.entryPoints=http,https
    - traefik.frontend.redirect.entryPoint=https
    - traefik.docker.network=proxy
    - traefik.port=80

1 个答案:

答案 0 :(得分:0)

labels:
- traefik.enabled=true
- traefik.port=80
- traefik.docker.network=proxy
- traefik.backend=oms_nginx
- traefik.frontend.rule=Host:mydomain.com
- traefik.frontend.headers.SSLRedirect=true   # <- it's a redirect only on 443 port
- traefik.frontend.entryPoints=http,https
- traefik.frontend.redirect.entryPoint=https  # <- It's the reditection label
- traefik.frontend.redirect=https             # <- non existing label
- traefik.http.redirect=https                 # <- non existing segment label
- traefik.http.frontend.entryPoints=http      # <- it's a segment label
- traefik.http.frontend.redirect=https        # <- it's a segment label
- traefik.https.frontend.entryPoints=https    # <- it's a segment label

前端重定向

traefik.toml

[entryPoints]
    [entryPoints.http]
    address = ":80"
    [entryPoints.https]
    address = ":443"
      [entryPoints.https.tls]
        [[entryPoints.https.tls.certificates]]
        certFile = "/etc/traefik/ssl/ee.crt"
        keyFile = "/etc/traefik/ssl/private.key"

将您的标签更改为:

...
labels:
- "traefik.enabled=true"
- "traefik.port=80"
- "traefik.docker.network=proxy"
- "traefik.backend=oms_nginx"
- "traefik.frontend.rule=Host:mydomain.com"
- "traefik.frontend.entryPoints=http,https"
- "traefik.frontend.redirect.entryPoint=https"

这假设您创建了2个名为httphttps的入口点。

全局重定向

traefik.toml

[entryPoints]
    [entryPoints.http]
    address = ":80"
      [entryPoints.http.redirect]
      entryPoint = "https"
    [entryPoints.https]
    address = ":443"
      [entryPoints.https.tls]
        [[entryPoints.https.tls.certificates]]
        certFile = "/etc/traefik/ssl/ee.crt"
        keyFile = "/etc/traefik/ssl/private.key"

docker-compose.yml

...
labels:
- "traefik.enabled=true"
- "traefik.port=80"
- "traefik.docker.network=proxy"
- "traefik.backend=oms_nginx"
- "traefik.frontend.rule=Host:mydomain.com"
- "traefik.frontend.entryPoints=http,https"