Advertisement
pilasguru

docker compose /app y traefik

Jun 16th, 2025
348
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.48 KB | Software | 0 0
  1. # Traefik console 8080
  2. # /app access 80
  3.  
  4. $ docker network create proxy
  5.  
  6. # ---
  7. services:
  8.   traefik:
  9.     image: traefik:latest
  10.     command:
  11.      - "--api.insecure=true"
  12.       - "--providers.docker=true"
  13.       - "--entrypoints.web.address=:80"
  14.     ports:
  15.      - "80:80"
  16.       - "8080:8080"
  17.     volumes:
  18.      - "/var/run/docker.sock:/var/run/docker.sock:ro"
  19.     networks:
  20.      - proxy
  21.     labels:
  22.      - "traefik.enable=false"
  23. networks:
  24.   proxy:
  25.     external: true
  26.  
  27. # ---
  28. services:
  29.   web:
  30.     image: nginx:latest
  31.     command: >-
  32.       bash -c "COLORS=('red' 'green' 'blue' 'yellow' 'cyan' 'magenta' 'orange' 'purple' 'pink' 'lime' 'teal' 'brown' 'gold' 'navy' 'olive' 'maroon' 'aqua' 'coral' 'salmon' 'violet');
  33.      COLOR=$${COLORS[$$RANDOM % $${#COLORS[@]}]};
  34.      echo \"<html><body style='background: $$COLOR; color: #ffffff; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0; font-size: 24px;'><h1>Mi color de fondo es $$COLOR</h1></body></html>\" > /usr/share/nginx/html/index.html && nginx -g 'daemon off;'"
  35.     labels:
  36.      - "traefik.enable=true"
  37.       - "traefik.http.routers.mi_servicio.rule=PathPrefix(`/app`)"
  38.       - "traefik.http.routers.mi_servicio.middlewares=strip-app"
  39.       - "traefik.http.middlewares.strip-app.stripprefix.prefixes=/app"
  40.       - "traefik.http.services.mi_servicio.loadbalancer.server.port=80"
  41.     deploy:
  42.       replicas: 3
  43.     networks:
  44.      - proxy
  45. networks:
  46.   proxy:
  47.     external: true
  48.  
  49.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement