反向代理不适用于docker swarm

时间:2019-04-20 09:41:25

标签: docker docker-swarm traefik

我使用traefik反向代理。以前,我使用带有反向代理的Docker容器,它可以正常工作。但是,当我切换到docker swarm时,traefik.frontend.rule不会意外运行。只能在Traefik信息中心中使用IP地址和端口。

Docker服务

docker service create 
    --name apiServer 
    --restart-condition=on-failure
    --network="domain-net"
    -p 8889:8889
    --label "traefik.backend=apiServer"
    --label "traefik.frontend.rule=Host:api.domain.com"
    --label "traefik.enable=true"
    --label "traefik.port=8889"
    --label "traefik.docker.network=domain-net"
    --label "traefik.frontend.headers.SSLRedirect=true"
    --label "traefik.frontend.headers.STSSeconds=315360000"
    --label "traefik.frontend.headers.browserXSSFilter=true"
    --label "traefik.frontend.headers.contentTypeNosniff=true"
    --label "traefik.frontend.headers.forceSTSHeader=true"
    --label "traefik.frontend.headers.SSLHost=domain.com"
    --label "traefik.frontend.headers.STSIncludeSubdomains=true"
    --label "traefik.frontend.headers.STSPreload=true"
    --label "traefik.frontend.headers.frameDeny=true"

Docker-compose.yml

version: "3.3"

services:
  traefik:
    image: traefik
    command: --web --docker --docker.swarmmode --docker.watch --docker.domain=domain.com --logLevel=DEBUG
    ports:
      - "80:80"
      - "8080:8080"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /etc/traefik/docker-swarm:/traefik.toml
    labels:
      - "traefik.enable=false"
    networks:
      - domain-net
    deploy:
      replicas: 1
      placement:
        constraints: [node.role==manager]
      restart_policy:
        condition: on-failure

networks:
  domain-net:
    driver: overlay

问题

api.domain.com显示错误521 Web服务器已关闭

0 个答案:

没有答案