Docker Swarm设置中的Traefik后面的后端无法访问

时间:2018-09-12 14:07:20

标签: traefik

我正在尝试通过Traefik反向代理和SSL终端将后端(python,端口9000)连接到外部。这是我第一次Traefik体验,因此在3个小时的文档阅读和配置后,我仍然可能会错过一些东西,而我对docker也很陌生。

我怀疑网络有问题。

到目前为止,该Swarm仅限于一个节点。这是设置。 Redis由后端使用,这基本上可以工作。问题是我无法通过Traefik到达后端。它只是不断加载并最终超时。

private IEnumerable<int> GetIdsByCommandLine(string commandLine)
{
    using (ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT ProcessID FROM Win32_Process WHERE CommandLine = " + commandLine))
    using (ManagementObjectCollection objects = searcher.Get())
    {
        foreach (var element in objects)                
            yield return (int) element["ProcessId"];                
    }
}

我在Traefik的日志输出中发现的东西

version: "3"

volumes:
  cs-api-config:

networks:
  webgateway:
    driver: overlay
    external: true
  traefik:
    driver: overlay
  api:
    driver: overlay

services:

  api:
    image: my-rep/my-api
    volumes:
      - cs-api-config:/app/config        
    networks:
      - traefik
      - api
    ports:
      - 9000
    deploy:
      restart_policy:
        condition: any
      mode: replicated
      replicas: 2
      placement:
        constraints: [node.role == manager]
      update_config:
        delay: 2s
      labels:
        - "traefik.docker.network=cs-api_traefik"
        - "traefik.port=9000"
        - "traefik.backend.loadbalancer.stickiness=true"
        - "traefik.backend.loadbalancer.swarm=true"
        - "traefik.frontend.rule=Host:my.domain.app"
        #        - "traefik.wss.protocol=http"

  redis:
    image: redis
    networks:
      - api
    ports:
      - 6379
    deploy:
      restart_policy:
        condition: any
      mode: replicated
      replicas: 1
      placement:
        constraints: [node.role == manager]
      update_config:
        delay: 2s

  loadbalancer:
    image: traefik
    command:
      - "--loglevel=DEBUG"
      - "--web"
      - "--entrypoints=Name:http Address::80 Redirect.EntryPoint:https"
      - "--entrypoints=Name:https Address::443 TLS"
      - "--defaultentrypoints=http,https"
      - "--acme"
      - "--acme.storage=/etc/traefik/acme/acme.json"
      - "--acme.entryPoint=https"
      - "--acme.onHostRule=true"
      - "--acme.onDemand=false"
      - "--acme.httpChallenge.entryPoint=http"
      - "--acme.email=myemail"
      - "--docker"
      - "--docker.swarmmode"
      - "--docker.domain=my.domain.app"
      - "--docker.watch"
    ports:
      - 80:80
      - 443:443
      - 9090:8080
    volumes:
      - cs-api-config:/etc/traefik/acme/
      - /var/run/docker.sock:/var/run/docker.sock
    deploy:
      restart_policy:
        condition: any
      mode: replicated
      replicas: 1
      update_config:
        delay: 2s
      placement:
         constraints: [node.role == manager]
    networks:
      - webgateway
      - traefik

后端获得内部IP,这些IP当然是无法公开访问的,但是我认为这应该由Traefik处理并转发到外部“ Webgateway”网络。

此外,我对Traefik感到困惑,抱怨缺少Redis的端口标签,我使用api将其放置在自己的网络中以摆脱此困扰,但Traefik仍然对此表示抱怨。它还抱怨自己的服务。

...    | time="2018-09-12T14:01:18Z" level=debug msg="No virtual IPs found in network 3npv6h0g3vjv2agnj3moqcz7m"
...    | time="2018-09-12T14:01:18Z" level=debug msg="No IP addresses found for network 3npv6h0g3vjv2agnj3moqcz7m"

在此先感谢您的帮助。

0 个答案:

没有答案
相关问题