Created
August 13, 2022 23:10
-
-
Save kahidna/bc162993c5b6e464f5a83a3db43a2165 to your computer and use it in GitHub Desktop.
traefik as reverse proxy and ssl termination on docker compose deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| version: '3.5' | |
| services: | |
| traefik: | |
| image: "traefik:v2.6" | |
| command: | |
| #- "--log.level=DEBUG" | |
| - "--api.insecure=true" | |
| - "--providers.docker=true" | |
| - "--providers.docker.exposedbydefault=false" | |
| - "--entrypoints.web.address=:80" | |
| # redirect http to https componenet, remark this if you still using http | |
| - "--entrypoints.websecure.address=:443" | |
| - "--entrypoints.web.http.redirections.entryPoint.to=websecure" | |
| - "--entrypoints.web.http.redirections.entryPoint.scheme=https" | |
| - "--entrypoints.web.http.redirections.entrypoint.permanent=true" | |
| # resolver for the letsencrypt certificate | |
| - "--certificatesresolvers.myresolver.acme.tlschallenge=true" # new | |
| - "--certificatesresolvers.myresolver.acme.email=admin@mail.com" #change the email admin | |
| - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json" | |
| ports: | |
| - "80:80" | |
| - "443:443" # new | |
| volumes: | |
| - "/var/run/docker.sock:/var/run/docker.sock:ro" | |
| - "./letsencrypt:/letsencrypt" # new | |
| networks: | |
| - compose_net | |
| aplication: | |
| image: kahidna/docker-nginx-php:7.4 | |
| container_name: application | |
| restart: always | |
| labels: | |
| - "traefik.enable=true" | |
| - "traefik.http.routers.frontend-sipa.rule=Host(`yourfqdn.domain`)" #replace the domain and or path | |
| - "traefik.http.routers.frontend-sipa.entrypoints=web,websecure" # remove websecure if you only use http | |
| - "traefik.http.routers.frontend-sipa.tls.certresolver=myresolver" | |
| networks: | |
| - compose_net | |
| networks: | |
| compose_net: | |
| name : compose_net | |
| driver: bridge | |
| ipam: | |
| driver: default | |
| config: | |
| - subnet: 172.18.19.0/24 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment