I have a docker-compose using traefik 1.7 to act as a proxy for my website. My website server is Next.js. I cannot manage to perform http to https redirection while having the same configuration working on other of my applications.
Here is my docker-compose.yml :
version: '2'
services:
proxy:
image: traefik:1.7
restart: always
command: |-
--logLevel=DEBUG
--web
--entrypoints='Name:http Address::80 Redirect.EntryPoint:https Redirect.Permanent:true'
#--entrypoints='Name:http Address::80'
--entrypoints='Name:https Address::443 TLS'
--docker
--acme
--acme.entrypoint=https
--acme.email=test@mail.com
--acme.storage=/etc/traefik/acme.json
--acme.ondemand=false
--acme.onhostrule=true
--acme.httpChallenge.entryPoint=http
networks:
- default
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./traefik:/etc/traefik/
website-preprod:
image: registry/taggedimage
restart: always
labels:
- "traefik.backend=my-website"
- "traefik.frontend.rule=Host:domainname.com"
- "traefik.docker.network=root_default"
- "traefik.frontend.entryPoints=http,https"
- "traefik.port=3000"
environment:
- HTTPS_CERT=server/certificates/dev.crt
- HTTPS_KEY=server/certificates/dev.key
- HTTP2=false
- API_ENDPOINT=https://api.domainname.com/api
- HTTPS=true
depends_on:
- proxy
networks:
- default
- inner
networks:
inner:
driver: bridge
internal: true
Https works, but the redirection from http to https does not. Traefik logs seems ok, except that it does not redirect at all.
It appears the comment #--entrypoints='Name:http Address::80'
was the issue there. Since docker-compose is translated to a command line, this line was breaking the previous line of the redirection.