traefik: entryPoints redirect not working
I want redirect in the following case http://mysite.com => https://www.mysite.com
and https://mysite.com => https://www.mysite.com
.
Why is not working?
traefik config
defaultEntryPoints = ["https"]
[entryPoints]
[entryPoints.http]
address = ":80"
[entryPoints.http.redirect]
regex = "^http://mysite.com/(.*)"
replacement = "https://www.mysite.com/$1"
[entryPoints.https]
address = ":443"
[entryPoints.https.tls]
[entryPoints.https.redirect]
regex = "^https://mysite.com/(.*)"
replacement = "https://www.mysite.com/$1"
[acme]
email = "..."
storageFile = "/acmestorage/acme.json"
entryPoint = "https"
[[acme.domains]]
main = "mysite.com"
sans = ["www.mysite.com"]
docker-compose for traefik
version: "2"
services:
proxy:
image: traefik:v1.1.1
command: --web --docker --docker.domain=mysite.com --logLevel=ERROR
volumes:
- ./config.toml:/traefik.toml
- ./storage:/acmestorage
- /var/run/docker.sock:/var/run/docker.sock:rw
ports:
- "80:80"
- "443:443"
- "8089:8080"
networks:
default:
external:
name: internal_network
docker-compose for app
version: "2"
services:
app:
image: golang:onbuild
command: app.bin -config=config.json -stderrthreshold=INFO -v=0
volumes:
- ./state/app:/go/src/app
- ./state/app/bin/app.bin:/usr/local/bin/app.bin
ports:
- 8080:80
links:
- postgres
- elasticsearch
labels:
- "traefik.backend=mysite"
- "traefik.port=80"
- "traefik.frontend.rule=Host:www.mysite.com"
#
#
#
networks:
default:
external:
name: internal_network
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 16 (3 by maintainers)
I found a work around based on @jibingeo 's comments, the following is a stripped down version of my configurations:
and my toml
It looks like You need to include
mysite.com
andwww.mysite.com
as a front-end rule. Traefik appears to re-route correctly, but for whatever reason, it’s needed as a front-end rule.No. We just stopped using traefik
After spending some time on this issue, I found that
http
tohttps
redirection won’t work if you don’t have matching front-end rule.ie. If
https://hello.com
return404
, thenhttp://hello.com
will also return404
instead of redirecting tohttps://hello.com