Traeffik没有在内部将传入的443映射到端口80

时间:2018-04-27 15:38:06

标签: traefik

我们的问题是来自https入口点的流量(可能)被转发到具有错误端口的后端。访问http入口点按预期工作:流量在服务器1 2 3之间进行负载平衡。使用https入口点时,我们得不到404页面。 TLS一切都很好,连接是安全的,但看起来traefik不会将后端服务器的端口更改为:80。

我们通过traefik进行加密,看起来不错。

以下是我们如何启动流量:

docker run -d -p 443:443 -p 80:80 -v /home/pi/lbtest/traefik/traefik.toml:/traefik.toml -v /home/pi/lbtest/traefik/acme.json:/acme.json traefik

这是我们的traefik.toml

debug = true

[file]

defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[frontends]
  [frontends.lbtest]
  backend = "lbtest"
    [frontends.lbtest.routes.route0]
    rule = "Host:xxx.gotdns.ch"

[backends]
  [backends.lbtest]
    [backends.lbtest.servers.server1]
    url = "http://192.168.178.81:80"
    [backends.lbtest.servers.server2]
    url = "http://192.168.178.49:80"
    [backends.lbtest.servers.server3]
    url= "http://192.168.178.64:80"


[acme]
email = "xxx@xxx.eu.com"
storageFile = "acme.json"
acmeLogging = true
entryPoint = "https"
onHostRule = true

[acme.httpChallenge]
entryPoint = "http"

[[acme.domains]]
main = "xxx.gotdns.ch"

为什么http://xxx.gotdns.ch有效 - 它在服务器1 2 3之间的负载平衡 - 但不适用于https://xxx.gotdns.ch。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

配置中的字段defaultEntryPoints存在问题:

debug = true

defaultEntryPoints = ["http", "https"] # <-- move the field here

[file]

[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[frontends]
  [frontends.lbtest]
  backend = "lbtest"
    [frontends.lbtest.routes.route0]
    rule = "Host:xxx.gotdns.ch"

[backends]
  [backends.lbtest]
    [backends.lbtest.servers.server1]
    url = "http://192.168.178.81:80"
    [backends.lbtest.servers.server2]
    url = "http://192.168.178.49:80"
    [backends.lbtest.servers.server3]
    url= "http://192.168.178.64:80"


[acme]
email = "xxx@xxx.eu.com"
storageFile = "acme.json"
acmeLogging = true
entryPoint = "https"
onHostRule = true

[acme.httpChallenge]
entryPoint = "http"

[[acme.domains]]
main = "xxx.gotdns.ch"

我建议您编写如下配置:

debug = true

defaultEntryPoints = ["http", "https"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]

[acme]
email = "xxx@xxx.eu.com"
storageFile = "acme.json"
acmeLogging = true
entryPoint = "https"
onHostRule = true

[acme.httpChallenge]
entryPoint = "http"

[[acme.domains]]
main = "xxx.gotdns.ch"

[file]
[frontends]
  [frontends.lbtest]
  backend = "lbtest"
    [frontends.lbtest.routes.route0]
    rule = "Host:xxx.gotdns.ch"

[backends]
  [backends.lbtest]
    [backends.lbtest.servers.server1]
    url = "http://192.168.178.81:80"
    [backends.lbtest.servers.server2]
    url = "http://192.168.178.49:80"
    [backends.lbtest.servers.server3]
    url= "http://192.168.178.64:80"