Hi Guys, we have a docker compose with a traefik (v2.11) as a proxy for multiple services (postgres, keycloak, api, front, ...)
I have a problem because a traefik hostname is accessible from the browser (nice) but not from a nodejs application that use fetch
. As far as i known it's probably a DNS issue, but i can't find a way to resolve it.
http:
routers:
traefik:
rule: "Host(`traefik.docker.localhost`)"
service: "api@internal"
tls:
domains:
- main: "docker.localhost"
sans:
- "*.docker.localhost"
tls:
certificates:
- certFile: "/etc/traefik/ssl/local-cert.pem"
keyFile: "/etc/traefik/ssl/local-key.pem"
global:
sendAnonymousUsage: false
api:
dashboard: true
insecure: true
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
watch: true
exposedByDefault: false
file:
filename: /etc/traefik/config.yml
watch: true
log:
level: INFO
format: common
accessLog: {}
entryPoints:
http:
address: ":80"
http:
redirections:
entryPoint:
to: https
scheme: https
https:
address: ":443"
postgres:
address: ":5432"
and the keycloak docker compose configuration
keycloak:
image: ${REGISTRY:-msdepi}/keycloak:${PLATFORM:-linux}-${TAG:-latest}
profiles:
- infra
build: ./.local/.keycloak
environment:
KEYCLOAK_ADMIN: admin
KEYCLOAK_ADMIN_PASSWORD: ${KEYCLOAK_ADMIN_PASSWORD}
KC_DB: postgres
KC_DB_URL_HOST: postgres
KC_DB_USERNAME: postgres
KC_DB_PASSWORD: ${POSTGRES_PASSWORD}
KC_DB_URL_DATABASE: ${DB_NAME}
KC_DB_SCHEMA: public
KC_PROXY: edge
KC_HTTP_ENABLE: true
KC_HTTP_HOST: 0.0.0.0
KC_HOSTNAME_STRICT: false
KC_HOSTNAME: keycloak.docker.localhost
command: start --import-realm
volumes:
- ./.local/.keycloak/realm-config/:/opt/keycloak/data/import/
depends_on:
postgres:
condition: service_healthy
labels:
- "traefik.enable=true"
- "traefik.http.services.keycloak.loadbalancer.server.port=8080"
- "traefik.http.services.keycloak.entrypoints=http"
- "traefik.http.routers.keycloak.rule=Host(`keycloak.docker.localhost`)"
- "traefik.http.routers.keycloak.tls=true"