简单的Traefik反向代理配置

Simple Traefik reverse proxy configuration

我正在使用以下配置启动 Traefik 版本 2.1.4:

defaultEntryPoints:
  - http

entryPoints:
  hole-1:
    address: ':663'

frontends:
  hole-frontend-1:
    backend: hole-backend-1
    entrypoints:
      - hole-1

backends:
  hole-backend-1:
    servers:
      hole-server-1:
        url: 'http://11.23.24.1:3000'
        weight: 10

当我点击 http://11.23.24.1:663 时,我看到了 Traefik 页面 404 pages not found。当我在浏览器中转到 http://11.23.24.1:3000 时,它起作用了,它显示了页面。

我似乎无法弄清楚如何在 Traefik 中设置反向代理以将 http://11.23.24.1:663 指向 http://11.23.24.1:3000

我试过了,但出现错误

2020/02/18 11:39:43 command traefik.exe error: no valid configuration found in file: C:\config\traefik.yaml

http:
  routers:
    hole-router-1:
      rule: "Host(`11.23.24.1`) && PathPrefix(`/`)"
      service: hole-service

services:
  hole-service:
    loadBalancer:
      servers:
        - url: http://11.23.24.1:3000

Traefik 2.1 不再支持前端和后端。 此存储库提供了一些示例来部署 Traefik 2.1 https://github.com/wshihadeh/traefik_v2

使用 Docker 的示例:

version: '3.7'

networks:
  traefik:
    external: true

volumes:
  db_data:

services:

  proxy:
    image: traefik:v2.1
    command:
      - '--providers.docker=true'
      - '--entryPoints.http.address=:80'
      - '--providers.providersThrottleDuration=2s'
      - '--providers.docker.watch=true'
      - '--providers.docker.exposedbydefault=false'
      - '--providers.docker.defaultRule=Host("local.me")'
      - '--accessLog.bufferingSize=0'
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock:ro'
    ports:
      - '663:80'
    deploy:
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      update_config:
        delay: 10s
        order: start-first
        parallelism: 1
      rollback_config:
        parallelism: 0
        order: stop-first
    logging:
      driver: json-file
      options:
        'max-size': '10m'
        'max-file': '5'
    networks:
      - traefik

   hole-backend:
    image:  hole-backend:demo-v1
    command: 'web'
    deploy:
      labels:
        - traefik.enable=true
        - traefik.http.services.hole.loadbalancer.server.port=8080
        - traefik.http.routers.hole.rule=Host(`hole.local.me`)
        - traefik.http.routers.hole.service=blog
        - traefik.http.routers.hole.entrypoints=web
        - traefik.docker.network=traefik
      restart_policy:
        condition: any
        delay: 5s
        max_attempts: 3
        window: 120s
      update_config:
        delay: 10s
        order: start-first
        parallelism: 1
      rollback_config:
        parallelism: 0
        order: stop-first
    logging:
      driver: json-file
      options:
        'max-size': '10m'
        'max-file': '5'
    networks:
      - traefik

C:\config\traefik\traefik.yaml:

entryPoints:
  hole-1:
    address: ":661"

providers:
  file:
    filename: C:\config\traefik\dynamic.yaml

C:\config\traefik\dynamic.yaml:

http:
  routers:
    hole-router-1:
      rule: "Path(`/`)"
      entryPoints:
        - hole-1
      service: hole-service

  services:
    hole-service:
      loadBalancer:
        servers:
          - url: http://10.23.24.10:3000

我开始使用 Traefik:traefik.exe --configFile=C:/config/traefik/traefik.yaml