Traefik负载均衡器未端口转发

时间:2019-03-09 04:44:07

标签: docker docker-compose port reverse-proxy traefik

因此,我尝试在此处跟随此示例(https://blog.tylerbuchea.com/docker-swarm-traefik-lets-encrypt-ssl-certificates/)。基本上,这是一个具有traefik.tomltraefik.yaml容器文件的docker群。整个过程是这样的,因为我已经有了很多工作,所以最终我可以得到ssl。

这是问题。上面的示例仅举一个容器的示例,然后立即使用command启动节点应用。我宁愿做如下事情。

这是我的docker-compose文件:

version: "3.3"

networks:
  default:
    external: false
  proxy:
    external: true

services:
  back:
    image: patientplatypus/lowtechback:latest
    ports: 
      - '5000:5000'
    networks:
      - proxy
      - default
    deploy:
      replicas: 3
      restart_policy:
        condition: on-failure
        max_attempts: 5
        window: 120s
      labels:
        - "traefik.docker.backend=back"
        - "traefik.port=5000"
        - "traefik.frontend.rule=Host:lowteck.com"
        - "traefik.docker.network=proxy"
  front:
    image: patientplatypus/lowtechfront:latest
    ports: 
      - '3000:3000'
    networks:
      - proxy
      - default
    depends_on:
      - back
    deploy:
      replicas: 3
      restart_policy:
        condition: on-failure
        max_attempts: 5
        window: 120s
      labels:
        - "traefik.docker.backend=front"
        - "traefik.port=3000"
        - "traefik.frontend.rule=Host:lowteck.com"
        - "traefik.docker.network=proxy"

请注意,前端正在寻找来自traefik.port=3000的传入数据,然后它将使用ports: 3000:3000将其转发到旋转图像中的3000。

现在这是我的traefik.yaml文件:

version: '3.3'

networks:
  proxy:
    external: true

configs:
  traefik.toml:
    file: ./traefik.toml

services:

  traefik:
    image: traefik
    ports:
      - "80:3000"
      - "8080:8080"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    configs:
      - source: traefik.toml
        target: /etc/traefik/traefik.toml
    labels:
      - "traefik.enable=false"
    networks:
      - proxy
    deploy:
      replicas: 1
      placement:
        constraints: [node.role == manager] 

因此,这将从端口80传入的数据分流到端口3000,对吗?因此,我希望当有人导航到lowteck.com时,他们应该跳80-traefik-3000->3000-docker compose-3000->3000-myImage。相反,我得到unable to connect。我已经测试过lowteck.com:3000并且可以正常工作,那么我在做什么错了?

0 个答案:

没有答案