Ошибка Traefik SSL в версии 2.1.4

У меня есть кластер Docker Swarm. В этом кластере мне нужно настроить Traefik с точкой входа SSL. как только я применил свою конфигурацию к traefik, он получил некоторую ошибку. Пожалуйста, помогите мне решить эту проблему.

Вот мой файл .toml,

logLevel = "INFO"

[docker]
  endpoint = "unix:///var/run/docker.sock"
  exposedbydefault = false

[api]
  dashboard =true

[entryPoints]
  [entryPoints.http]
  address = ":80"
    [entryPoints.http.redirect]
    entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]
      [[entryPoints.https.tls.certificates]]
      certFile = "/root/ssl/mi-synergy.com.crt"
      keyFile = "/root/ssl/mi-synergy.com.key"

Вот мой файл стека

version: "3.7"
services:
  traefik:
    image: traefik:2.1.4
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /root/traefik.toml:/etc/traefik/traefik.toml
      - /root/ssl:/root/ssl
    networks:
      - webgateway
      - traefik
    ports:
      - 80:80
      - 443:443
      - 8080:8080
    deploy:
      mode: global
      placement:
        constraints:
          - node.role == manager
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: on-failure

networks:
  webgateway:
    driver: overlay
  traefik:
    driver: overlay

Выдержка из журнала

[email protected]    | 2020/02/25 14:29:58 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:30:06 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:30:14 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:30:22 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:30:30 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:30:38 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:30:46 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:30:54 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:31:02 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:31:09 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:31:17 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:31:25 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:31:33 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:31:41 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:31:49 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:31:57 command traefik error: field not found, node: redirect
[email protected]    | 2020/02/25 14:32:05 command traefik error: field not found, node: redirect

person Damith Udayanga    schedule 25.02.2020    source источник
comment
Вы можете поделиться своим файлом стека traefik?   -  person Al-waleed Shihadeh    schedule 25.02.2020
comment
Бро, я редактирую пост и отправляю файл стека   -  person Damith Udayanga    schedule 26.02.2020
comment
Да, но вам также необходимо указать конфигурацию целевого контейнера.   -  person Sam Texas    schedule 26.02.2020


Ответы (1)


вы можете попробовать следующий стек докеров

version: "3.7"
services:
  traefik:
    image: traefik:2.1.4
    command:
      - '--providers.docker=true'
      - '--providers.providersThrottleDuration=2s'
      - '--providers.docker.watch=true'
      - '--providers.docker.swarmMode=true'
      - '--providers.docker.swarmModeRefreshSeconds=15s'
      - '--providers.docker.exposedbydefault=false'
      - '--providers.docker.defaultRule=Host("${REPLACE_WITH_YOUR_DOMAIN}")'
      - '--accessLog.bufferingSize=0'
      - '--api=true'
      - '--api.dashboard=true'
      - '--api.insecure=true'
      - '--ping.entryPoint=web'
      - '--providers.file.filename=/run/traefik.toml'
      - '--entryPoints.web.address=:80'
      - '--entryPoints.websecure.address=:443'
    volumes:
      - '/var/run/docker.sock:/var/run/docker.sock:ro'
      - '/root/traefik.toml:/run/traefik.toml'
      - '/root/ssl:/root/ssl'
    networks:
      - webgateway
      - traefik
    ports:
      - 80:80
      - 443:443
      - 8080:8080
    deploy:
      labels:
        - traefik.enable=true
        - traefik.docker.network=traefik
        - traefik.http.middlewares.https_redirect.redirectscheme.scheme=https
        - traefik.http.middlewares.https_redirect.redirectscheme.permanent=true
        - traefik.http.routers.http_catchall.rule=HostRegexp(`{any:.+}`)
        - traefik.http.routers.http_catchall.entrypoints=web
        - traefik.http.routers.http_catchall.middlewares=https_redirect
      mode: global
      placement:
        constraints:
          - node.role == manager
      update_config:
        parallelism: 1
        delay: 10s
      restart_policy:
        condition: on-failure

networks:
  webgateway:
    driver: overlay
  traefik:
    driver: overlay

traefik.toml

[[tls.certificates]]
  certFile = "/root/ssl/mi-synergy.com.crt"
  keyFile = "/root/ssl/mi-synergy.com.key"

убедитесь, что сертификаты ssl существуют на хост-компьютере под /root/ssl и файл конфигурации traefik под /root/traefik.toml, в противном случае он не будет доступен для контейнера. если вы используете это в многоузловом рое, он должен быть на всех узлах (не только в менеджере), так как вы использовали режим глобального развертывания.

person Al-waleed Shihadeh    schedule 26.02.2020