使用以下配置,我的网址会自动重定向到https
但内容并不直接。
这是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
答案 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个名为http
和https
的入口点。
在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"