Created
July 5, 2023 20:45
-
-
Save kazem3d/2f777de7977a52ff8c40334f4cd9d51a to your computer and use it in GitHub Desktop.
nginx and traefik with ssl/tls deployment with docker-compose [simple mode]
This file contains 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
# nginx and traefik with ssl/tls deployment with docker-compose [simple mode] | |
# http -> https redirect is not config and hendeled in dns resolver | |
version: '3.8' | |
services: | |
traefik: | |
image: traefik:v2.4 | |
command: | |
- "--api.insecure=true" # Enable insecure mode for the Traefik UI | |
- "--providers.docker=true" | |
- "--providers.docker.exposedbydefault=false" | |
- "--entrypoints.web.address=:80" | |
- "--entrypoints.websecure.address=:443" # Enable HTTPS entrypoint on port 443 | |
- "--certificatesresolvers.myresolver.acme.tlschallenge=true" # Use TLS challenge | |
- "--certificatesresolvers.myresolver.acme.email=sample3d@gmail.com" # Set your email for Let's Encrypt notifications | |
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json" # Provide a path to store the Let's Encrypt certificates | |
ports: | |
- "80:80" # Expose port 80 for HTTP | |
- "443:443" # Expose port 443 for HTTPS | |
volumes: | |
- "/var/run/docker.sock:/var/run/docker.sock:ro" # Mount Docker socket | |
- "./letsencrypt:/letsencrypt" # Mount the Let's Encrypt certificate storage | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.traefik.rule=Host(`my.sample47.ir`)" # Set domain rule for Traefik UI | |
- "traefik.http.routers.traefik.service=api@internal" | |
- "traefik.http.routers.traefik.tls.certresolver=myresolver" # Enable TLS for Traefik UI | |
nginx: | |
image: nginx:latest | |
labels: | |
- "traefik.enable=true" | |
- "traefik.http.routers.nginx.rule=Host(`f.sample47.ir`)" | |
- "traefik.http.routers.nginx.entrypoints=websecure" # Use HTTPS entrypoint | |
- "traefik.http.routers.nginx.tls.certresolver=myresolver" # Enable TLS for Nginx | |
- "traefik.http.services.nginx.loadbalancer.server.port=80" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment