Hello community! I'm trying to configure a weird setup. Server hosts an Apache server that listens on 80 and 443 (random.domain). Traefik listens on 65000 (HTTP) and 65001 (HTTPS) for a different domain (subdomain.random.domain and some.random.domain). Traefik dashboard listens on localhost:65002.
The issue I have is that when I make a request for http://subdomain.random.domain:65000 or http://some.random.domain:65000 redirection to HTTPS indeed takes place, however I'm presented with the certificate that Apache serves for https://random.domain. I'm not sure why this happens but it looks like Traefik when redirecting to HTTPS routes traffic to localhost:443 instead of Traefik's entrypoint (443).
Would appreciate if anyone could point me to the right direction.
This is my configuration:
traefik.toml
[entryPoints]
[entryPoints.dashboard]
address = ":9090"
[entryPoints.web]
address = ":80"
[entryPoints.web.http]
[entryPoints.web.http.redirections]
[entryPoints.web.http.redirections.entryPoint]
to = "websecure"
scheme = "https"
[entryPoints.websecure]
address = ":443"
[api]
dashboard = true
[providers]
[providers.file]
directory = "/dynconf"
watch = true
[providers.docker]
endpoint = "unix:///var/run/docker.sock"
network = "traefik_network"
exposedByDefault = false
docker-compose.yml
version: '3.7'
services:
# traefik service
traefik:
image: "traefik:v2.2"
labels:
- "traefik.enable=true"
- "traefik.http.routers.to-dashboard.rule=Host(`dashboard.local`)"
- "traefik.http.routers.to-dashboard.entrypoints=dashboard"
- "traefik.http.routers.to-dashboard.middlewares=auth"
- "traefik.http.routers.to-dashboard.service=api@internal"
- "traefik.http.middlewares.auth.basicauth.users=admin:<PASSWORD>"
container_name: "traefik"
ports:
- "65000:80"
- "65001:443"
- "127.0.0.1:65002:9090"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "/home/traefik/traefik.toml:/traefik.toml:ro"
- "/home/traefik/letsencrypt/acme.json:/acme.json"
- "/home/traefik/dynconf/dyn.toml:/dynconf/dyn.toml"
- "/home/traefik/certs/:/certs/"
httpecho:
image: "hashicorp/http-echo"
container_name: "httpecho"
command: "-text='hello world!'"
labels:
- "traefik.enable=true"
- "traefik.http.routers.to-httpecho.rule=Host(`subdomain.random.domain`)"
- "traefik.http.routers.to-httpecho.entrypoints=web"
- "traefik.http.routers.to-httpecho.middlewares=https_redirect"
- "traefik.http.routers.to-httpecho-secure.rule=Host(`subdomain.random.domain`)"
- "traefik.http.routers.to-httpecho-secure.entrypoints=websecure"
- "traefik.http.routers.to-httpecho-secure.tls=true"
- "traefik.http.middlewares.https_redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.https_redirect.redirectscheme.permanent=true"
whoami:
image: "traefik/whoami"
container_name: "whoami"
labels:
- "traefik.enable=true"
- "traefik.http.routers.to-whoami.rule=Host(`some.random.domain`)"
- "traefik.http.routers.to-whoami.entrypoints=web"
- "traefik.http.routers.to-whoami.middlewares=https_redirect"
- "traefik.http.routers.to-whoami-secure.rule=Host(`some.random.domain`)"
- "traefik.http.routers.to-whoami-secure.entrypoints=websecure"
- "traefik.http.routers.to-whoami-secure.tls=true"
- "traefik.http.middlewares.https_redirect.redirectscheme.scheme=https"
- "traefik.http.middlewares.https_redirect.redirectscheme.permanent=true"
networks:
default:
external:
name: "traefik_network"