Skip to content

Instantly share code, notes, and snippets.

@kazem3d
Created July 5, 2023 20:44
Show Gist options
  • Save kazem3d/dcd6795536db203d53c0e39af95ab4c5 to your computer and use it in GitHub Desktop.
Save kazem3d/dcd6795536db203d53c0e39af95ab4c5 to your computer and use it in GitHub Desktop.
nginx and traefik deployment with docker-compose [http only]
# nginx and traefik deployment with docker-compose [http only]
version: '3.8'
services:
traefik:
image: traefik
command:
- "--api.insecure=true" # Enable insecure mode for the Traefik UI
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
ports:
- "80:80" # Expose port 80 for Traefik UI
- "8080:8080" # Expose port 8080 for Traefik API dashboard
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro" # Mount Docker socket
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"
nginx:
image: nginx:latest
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx.rule=Host(`f.sample47.ir`)" # Set domain rule for Nginx
- "traefik.http.routers.nginx.entrypoints=web"
- "traefik.http.services.nginx.loadbalancer.server.port=80" # Expose Nginx on port 80
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment