" /> " />

目 录CONTENT

文章目录

docker 部署 traefik

Administrator
2024-11-20 / 0 评论 / 0 点赞 / 3 阅读 / 3109 字

导读

Traefik is a leading modern open source reverse proxy and ingress controller that makes deploying services and APIs easy. Traefik integrates with your existing infrastructure components and configures itself automatically and dynamically.

部署

version: "3"

services:
  traefik:
    image: traefik:v3.0
    restart: always
    ports:
      - 80:80
      - 81:8080
    command:
      - "--api=true"
      # - "--api.dashboard=true"
      - "--api.insecure=true"
      - "--ping=true"
      - "--entrypoints.http.address=:80"
      # - "--entrypoints.web.address=:80"
      - "--providers.docker=true"
      - "--providers.docker.endpoint=unix:///var/run/docker.sock"
    labels:
      # - "traefik.http.routers.traefik-dashboard.entrypoints=http"
      # - "traefik.http.routers.traefik-dashboard.rule=Host(`traefik.console.lab.io`)"
      # - "traefik.http.routers.traefik-dashboard.service=dashboard@internal"
      # - "traefik.http.routers.traefik-dashboard-api.entrypoints=http"
      # - "traefik.http.routers.traefik-dashboard-api.rule=Host(`traefik.console.lab.io`) && PathPrefix(`/api`)"
      # - "traefik.http.routers.traefik-dashboard-api.rule=PathPrefix(`/api`)"
      # - "traefik.http.routers.traefik-dashboard-api.service=api@internal"

      - "traefik.http.middlewares.gzip.compress=true"
      - "traefik.http.routers.traefik-dashboard.middlewares=gzip@docker"
      - "traefik.http.routers.traefik-dashboard-api.middlewares=gzip@docker"

      # - "traefik.http.routers.backend-x.rule=Host(`backend-x`) && PathPrefix(`/x/`)"
      # - "traefik.http.routers.backend-auth-service.rule=PathPrefix(`/auth/`)"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
    healthcheck:
      test: ["CMD-SHELL", "wget -q --spider --proxy off localhost:8080/ping || exit 1"]
      interval: 3s
      retries: 10
    logging:
      driver: "json-file"
      options:
        max-size: "1m"
    networks:
      - platform-common-net
    hostname: traefik.local

  # whoami:
  #   # 验证traefik服务
  #   image: "traefik/whoami"
  #   labels:
  #     - "traefik.enable=true"
  #     - "traefik.http.routers.whoami.rule=Host(`whoami.localhost`)"
  #     - "traefik.http.routers.whoami.entrypoints=http"
  #   networks:
  #     - platform-common-net
  #   hostname: whoami.local

networks:
  platform-common-net:
    external: true

0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区