I'm getting too many redirect error when I try to visit dashboard or any other hosted container. This is my container.yml
content:
services:
traefik:
image: traefik:v2.11
restart: always
container_name: traefik
ports:
- "80:80" # <== http
- "8080:8080" # <== dashboard
- "443:443" # <== https
command:
- --api.insecure=true # <== Enabling insecure api, NOT RECOMMENDED FOR PRODUCTION
- --api.dashboard=true # <== Enabling the dashboard to view services, middlewares, routers, etc.
- --api.debug=false # <== Enabling additional endpoints for debugging and profiling
- --log.level=ERROR # <== Setting the level of the logs from traefik
- --providers.docker=true # <== Enabling docker as the provider for traefik
- --providers.docker.exposedbydefault=false # <== Don't expose every container to traefik
- --providers.docker.network=proxy # <== Operate on the docker network named web
- --entrypoints.web.address=:80 # <== Defining an entrypoint for port :80 named web
- "--entryPoints.web.forwardedHeaders.insecure"
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik-data/config/traefik.yml:/traefik.yml:ro
- ./traefik-data/config/acme.json:/acme.json
- ./traefik-data/config/config.yml:/config.yml:ro
- ./traefik-data/logs:/var/log/traefik
environment:
- CF_API_EMAIL=cf-email@gmail.com
- CF_DNS_API_TOKEN=CLOUDFLARE_TOKEN
networks:
- proxy # <== Placing traefik on the network named proxy, to access containers on this network
labels:
- "traefik.enable=true" # <== Enable traefik on itself to view dashboard and assign subdomain to$
- "traefik.http.routers.traefik.entrypoints=http"
- "traefik.http.routers.traefik.rule=Host(`config.my-domain.com`)"
- "traefik.http.middlewares.traefik-auth.basicauth.users=user:password"
- "traefik.http.middlewares.traefik-https-redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.sslheader.headers.customrequestheaders.X-Forwarded-Proto=https"
- "traefik.http.routers.traefik.middlewares=traefik-https-redirect"
- "traefik.http.routers.traefik-secure.entrypoints=https"
- "traefik.http.routers.traefik-secure.rule=Host(`config.my-domain.com`)"
- "traefik.http.routers.traefik-secure.middlewares=traefik-auth"
- "traefik.http.routers.traefik-secure.tls=true"
- "traefik.http.routers.traefik-secure.tls.certresolver=cloudflare"
- "traefik.http.routers.traefik-secure.tls.domains[0].main=my-domain.com"
- "traefik.http.routers.traefik-secure.tls.domains[0].sans=*.my-domain.com"
- "traefik.http.routers.traefik-secure.service=api@internal"
networks:
proxy:
This is content for traefik.yml
:
api:
dashboard: true
debug: true
entryPoints:
http:
address: ":80"
http:
redirections:
entryPoint:
to: https
scheme: https
https:
address: ":443"
serversTransport:
insecureSkipVerify: true
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
file:
filename: /config.yml
certificatesResolvers:
cloudflare:
acme:
email: cf-email@gmail.com
storage: acme.json
dnsChallenge:
provider: cloudflare
#disablePropagationCheck: true # uncomment this if you have issues pulling certificates through cloudflare, By setting this flag to true disables the need to wait for the propagation of the TXT record to all authoritative name servers.
resolvers:
- "1.1.1.1:53"
- "1.0.0.1:53"
My config.yml
file is empty.
I want to redirect http to https. What am I doing wrong here?
Also, is there any way to only expose dashboard to the local computer but not to internet?
I'm new to Traefik so I might be making some silly mistake here. Thanks for any suggestion.