Использовать traefik в качестве обратного прокси для сервисов Docker и не-Docker - PullRequest
0 голосов
/ 17 апреля 2019

В настоящее время я пытаюсь настроить Traefik для маршрутизации к нескольким док-контейнерам и нескольким не-докерским приложениям, расположенным на другой машине, расположенной в 10.0.1.4 на порте 8080 и 5000

Пока что яполучил панель инструментов Traefik и Let's Encrypt и работает вместе с моими док-приложениями, но я не могу заставить внешние приложения перенаправлять на другую машину

Вот мой traefik.toml

defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.dashboard]
    address = ":8080"
    [entryPoints.dashboard.auth]
      [entryPoints.dashboard.auth.basic]
        users = ["admin:xxxx"]
  [entryPoints.http]
    address = ":80"
      [entryPoints.http.redirect]
        entryPoint = "https"
  [entryPoints.https]
    address = ":443"
      [entryPoints.https.tls]

[api]
entrypoint="dashboard"

[acme]
email = "xxx@example.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true
  [acme.httpChallenge]
  entryPoint = "http"

[docker]
domain = "example.com"
watch = true
network = "web"


[file]

[backends]

  # Set name of backend describing Rancher. We name it "app1".
  [backends.app1]

    [backends.app1.servers]

      [backends.app1.servers.server0]

        # URL to app1 server.
        url = "http://10.0.1.4:5000"

        # As this is a single instance app1, we can set the weight to 1. All requests will be handled by this server.
        weight = 1

  # Set name of backend describing Rancher. We name it "app2".
  [backends.app2]

    [backends.app2.servers]

      [backends.app2.servers.server0]

        # URL to app2 server.
        url = "http://10.0.1.4:8181"

        # As this is a single instance app2, we can set the weight to 1. All requests will be handled by this server.
        weight = 1


[frontends]

  # Set name of frontend describing app1. We use the same name "app1".
  [frontends.app1]

    # Backend which will handle requests.
    backend = "app1"

    # Forward client Host header to the backend.
    passHostHeader = true

      [frontends.app1.routes]

        [frontends.app1.routes.route0]

          # Use this frontend only when the request contains Host header with our domain.
          rule = "Host:application1.example.com"

  # Set name of frontend describing app2. We use the same name "app2".
  [frontends.app2]

    # Backend which will handle requests.
    backend = "app2"

    # Forward client Host header to the backend.
    passHostHeader = true

      [frontends.app2.routes]

        [frontends.app2.routes.route1]

          # Use this frontend only when the request contains Host header with our domain.
          rule = "Host:application2.example.com"

А вот мой код для моего docker-compose.yml

version: "3"

networks:
  web:
    external: true
  internal:
    external: false

Я надеюсь, что мои домены перейдут на application1.example.com и application2.example.com.Любая помощь будет оценена.Спасибо!

...