I use docker-compose to run traefik,Two endpoints are enabled: http,https
I get this error when I visit the https endpoint:
time="2021-05-02T09:29:01+08:00" level=debug msg="http: TLS handshake error from 113.104.217.157:9575: write tcp 172.19.0.2:443->xxx.xxx.217.157:9575: write: connection reset by peer"
curl http://domain.com/api/
Good!
curl https://domain.com/api/
Bad!
Get error in most cases, after visiting twenty or thirty times, it is normal.
Visited a few more times and got error again Why?
curl http://domain.com:443/api/
Good!
traefik.yaml
version: '3.3'
services:
traefik:
image: traefik:v2.4.8
container_name: 'traefik'
restart: always
networks:
- traefik
environment:
ALICLOUD_ACCESS_KEY: XXXXXXX
ALICLOUD_SECRET_KEY: XXXXXXXXXXXXXXX
command:
- "--api.insecure=true"
- "--api.dashboard=true"
- "--providers.docker=true"
- "--providers.docker.network=traefik"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.http.address=:80"
- "--entrypoints.https.address=:443"
- "--certificatesresolvers.default.acme.email=xxxxxxxxxxx"
- "--certificatesresolvers.default.acme.storage=/etc/traefik/acme.json"
- "--certificatesresolvers.default.acme.dnschallenge=true"
- "--certificatesresolvers.default.acme.dnschallenge.provider=alidns"
- "--log.level=TRACE"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /root/software/traefik/acme/:/etc/traefik/
networks:
traefik:
external: true
app docker-compose.yml
version: '3.3'
services:
miya-service:
build:
context: .
dockerfile: Dockerfile
image: miya-service:latest
container_name: 'miya-service'
restart: always
labels:
traefik.http.routers.miya-service.rule: "Host(`domain.com`) && PathPrefix(`/api`)"
traefik.enable: "true"
traefik.http.routers.miya-service.entrypoints: "http,https"
traefik.http.services.miya-service.loadbalancer.server.port: "8080"
traefik.http.routers.miya-service.tls: "true"
traefik.http.routers.miya-service.tls.certresolver: "default"
networks:
- traefik
- db
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
traefik:
external: true
db:
external: true