Good afternoon, everyone! I can't set up redirect http to https. I'm new to traefik and I'm asking for help. I want to have all traffic automatically redirected from http to https
my settings:
traefik.yml
entryPoints:
http:
address: ":80"
https:
address: ":443"
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
directory: /custom
watch: true
certificatesResolvers:
letsEncrypt:
acme:
email: ser@domain.com
storage: /ssl/acme.json
httpChallenge:
entryPoint: http
api:
dashboard: true
docker-compose.yml
version: '3'
services:
traefik:
image: traefik:v2.11
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
ports:
- 80:80
- 443:443
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- /opt/service/traefik/data/traefik.yml:/traefik.yml:ro
- /opt/service/traefik/ssl:/ssl
- /opt/service/traefik/data/custom/:/custom/:ro
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.entrypoints=https"
- "traefik.http.routers.traefik.rule=Host(`traefik.domain.com`)"
- "traefik.http.routers.traefik.tls=true"
- "traefik.http.routers.traefik.tls.certresolver=letsEncrypt"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.services.traefik-traefik.loadbalancer.server.port=888"
- "traefik.http.middlewares.traefik-auth.basicauth.users=adam:$$apr1$$fu19VK6K$$GTJdIIdeWJiOHQGssq23B9O1/"
- "traefik.http.routers.traefik.middlewares=traefik-auth"
dynamic file
http:
routers:
front:
entryPoints:
- https
service: front-host
rule: Host(`front.domain.com`)
tls:
certResolver: letsEncrypt
services:
front-host:
loadBalancer:
servers:
- url: http://8.8.8.8:8080/
passHostHeader: true
if I add lines to traefik.yml then nothing happens
http:
routers:
http-catchall:
rule: hostregexp(`{host:.+}`)
entrypoints:
- http
middlewares:
- redirect-to-https
middlewares:
redirect-to-https:
redirectScheme:
scheme: https
permanent: false
http://front.domain.com - it should redirect to https://front.domain.com and instead of that "404 page not found"
https://front.domain.com - 200 ok
Thanks for the answers!