lets create tnet
first with:
docker network create tnet
then create traefik
folder and put following contents to docker-compose.yml
version: "3.9"
services:
traefik:
image: traefik
restart: always
command:
- "--log.level=DEBUG"
- '--providers.docker.exposedByDefault=false'
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--serverstransport.insecureskipverify=true"
- "--certificatesresolvers.le.acme.storage=/acme.json"
- "--certificatesresolvers.le.acme.tlschallenge=true"
- "--certificatesresolvers.le.acme.httpchallenge.entrypoint=web"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
labels:
- traefik.enable=true
ports:
- "80:80"
- "443:443"
networks:
- lanuske
networks:
tnet:
name: tnet
external: true
enter traefik
directory and run docker-compose up -d
and config for each "microservice"
version: "3.9"
# other containres
# db:
# image: mariadb:latest
# this with traefik tags, will be exposed to the internet with a subdomain name
nginx:
image: nginx
restart: always
labels:
- traefik.enable=true
- traefik.http.routers.your-uniq-router-http.entrypoints=web
- traefik.http.routers.your-uniq-router-http.rule=Host(`container-name.domain.tld`)
- traefik.http.routers.your-uniq-router-https.entrypoints=websecure
- traefik.http.routers.your-uniq-router-https.rule=Host(`container-name.domain.tld`)
- traefik.http.routers.your-uniq-router-https.tls.certresolver=le
- traefik.http.routers.your-uniq-router-https.tls=true
- traefik.http.services.your-uniq-router-https.loadbalancer.server.port=80 #nginx port
networks:
- tnet
networks:
tnet:
name: tnet
external: true
Top comments (0)