Traefik v2 в качестве обратного прокси без докера - PullRequest
1 голос
/ 22 октября 2019

Я прочитал документацию, но не могу понять, как настроить Traefik v2 для замены Nginx в качестве обратного прокси-сервера для веб-сайтов (виртуальных хостов) без привлечения Docker. В идеале было бы разрешено также шифровать https.

У меня есть служба, работающая на http://127.0.0.1:4000, для которой я бы хотел изменить прокси с http://myhost.com:80

ЭтоКонфигурация, которую я придумала до сих пор:

[Global]
checkNewVersion = true

[log]
  level = "DEBUG"
  filePath = "log-file.log"

[accessLog]
  filePath =  "log-access.log"
  bufferingSize =  100

[entrypoints]
    [entrypoints.http]
    address = ":80"

[http]
    [http.routers]
       [http.routers.my-router]
          rule = "Host(`www.myhost.com`)"
          service = "http"
          entrypoint=["http"]

    [http.services]
          [http.services.http.loadbalancer]
            [[http.services.http.loadbalancer.servers]]
              url = "http://127.0.0.1:4000"

1 Ответ

1 голос
/ 22 октября 2019

Я понял, первая часть, на которую следует обратить внимание, это то, что в traefik v2 есть два типа конфигурации, статическая и динамическая. Поэтому я создал два файла, traefik.toml и traefik-dynamic.toml.

содержимое файла traefik.toml:

[log]
  level = "DEBUG"
  filePath = "log-file.log"

[accessLog]
  filePath =  "log-access.log"
  bufferingSize =  100

[providers]
  [providers.file]
    filename = "traefik-dynamic.toml"

[api]
  dashboard = true
  debug = true

[entryPoints]
  [entryPoints.web]
    address = ":80"
  [entryPoints.web-secure]
    address = ":443"
  [entryPoints.dashboard]
    address = ":8080"

[certificatesResolvers.sample.acme]
  email = "myemail@example.com"
  storage = "acme.json"

  [certificatesResolvers.sample.acme.httpChallenge]
    # used during the challenge
    entryPoint = "web"

traefik-dynamic.toml:

[http]
    # Redirect to https
    [http.middlewares]
      [http.middlewares.test-redirectscheme.redirectScheme]
        scheme = "https"

    [http.routers]
       [http.routers.my-router]
          rule = "Host(`www.example.com`)"
          service = "phx"
          entryPoints = ["web-secure"]
       [http.routers.my-router.tls]
          certResolver = "sample"

    [http.services]
          [http.services.phx.loadbalancer]
            [[http.services.phx.loadbalancer.servers]]
              url = "http://127.0.0.1:4000"
...