My docker-compose file is as follows:
version: "2"
services:
api:
restart: always
image: private_repo/middleware:2.0
ports:
- "7000:5000"
volumes:
- swagger-ui:/opt/www/app/templates
labels:
- "traefik.enable=true"
- "traefik.http.middlewares.redirect-middleware.redirectscheme.scheme=https"
- "traefik.http.routers.api.entrypoints=frontendssl"
- "traefik.http.routers.api.middlewares=redirect-to-https"
- "traefik.http.routers.api.rule=Host(`traefik.cicd.dev`)"
- "traefik.http.services.api.loadbalancer.server.port=7000"
traefik:
image: "traefik:v2.3"
container_name: "traefik"
command:
- "--api.insecure=true"
- "--api.dashboard=true"
- "--api.debug=true"
- "--log=true"
- "--log.level=DEBUG"
- "--entrypoints.frontend.address=:80"
- "--entrypoints.frontendssl.address=:443"
- "--entrypoints.frontendssl.http.tls=true"
- "--providers.docker=true"
- "--providers.docker.watch=true"
- "--providers.docker.endpoint=unix:///var/run/docker.sock"
- "--providers.docker.exposedbydefault=true"
- "--providers.file.filename=/home/core/k8s_to_compose/traefik.yml"
- "--providers.file.watch=true"
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`traefik.cicd.dev`)"
- "traefik.http.routers.traefik.entrypoints=frontendssl"
- "traefik.http.routers.traefik.service=api@internal"
- "traefik.http.routers.traefik.middlewares=redirect-to-https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- ./certs/:/home/core/k8s_to_compose/certs/:ro
- ./traefik.yml:/home/core/k8s_to_compose/traefik.yml:ro
Here I have generated self signed certificates using openssl and also as I don't own a domain, so I have used <vm-ip-address> traefik.cicd.dev
entry added into /etc/hosts
.
Here issues what I observe is :
- The traefik dashboard is not accessible with
https://traefik.cicd.dev:8080
but it can be accessed withhttp://<vm-ip-address>:8080
- When I browse
https://traefik.cicd.dev:7000
to access my api container UI as in above docker-compose file, the chrome browser is showing:This site can’t provide a secure connectiontraefik.cicd.dev sent an invalid response.ERR_SSL_PROTOCOL_ERROR
.
But I can access when I browse withhttp://<vm-ip-address>:7000
Here Im trying get it working with https but could not achieve it. While debugging as suggested in community for similar issues, I have set --api.insecure=true
as well, but no luck. Please help.