首页 文章

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

提问于
浏览
0

我们的问题是来自https入口点的流量(可能)被转发到具有错误端口的后端 . 访问http入口点按预期工作:流量在服务器1 2 3之间进行负载 balancer . 使用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之间的负载 balancer - 但不是https://xxx.gotdns.ch . 有任何想法吗?

1 回答

  • 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"
    

相关问题