首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >群: Traefik在组合服务上返回404

群: Traefik在组合服务上返回404
EN

Stack Overflow用户
提问于 2020-05-14 20:48:37
回答 1查看 569关注 0票数 1

我有两个运行Docker的设备: Intel NUC和Raspberry Pi。我的NUC用作mediaplayer/mediaserver。这也是管理节点。Pi被用作家庭助理和MQTT机器,并被设置为工作者节点。我想把它们添加到一个群中,这样我就可以在两台机器上使用Traefik作为反向代理和HTTPS。

NUC:

1码头-为Traefik,领事和维护者撰写文件。

为我的媒体应用程序(Sabnzbd,Transmission,Sonarr,Radarr等)编写文件。

派:

1码头-为家庭助理,MQTT等撰写文件。

Traefik和维护者已经开始运作了。我给他们安排了docker stack deploy。接下来,我尝试设置我的媒体应用程序,但它们不需要与Pi连接,所以我尝试了docker compose。维护者显示应用程序正在运行,但当我进入他们的子域Traefik返回404页找不到。这使我得出结论,运行在群外但与Traefik连接的应用程序不起作用。他们也不会出现在Traefik仪表盘上。

docker-compose.traefik.yml -‘码头堆栈部署’

代码语言:javascript
运行
复制
version: '3.7'

networks:
  traefik_proxy:
    external: true
  agent-network:
    attachable: true

volumes:
  consul-data-leader:
  consul-data-replica:
  portainer-data:

services:
  consul-leader:
    image: consul
    command: agent -server -client=0.0.0.0 -bootstrap -ui
    volumes:
      - consul-data-leader:/consul/data
    environment:
      - CONSUL_BIND_INTERFACE=eth0
      - 'CONSUL_LOCAL_CONFIG={"leave_on_terminate": true}'
    networks:
      - traefik_proxy
    deploy:
      labels:
        - traefik.frontend.rule=Host:consul.${DOMAINNAME?Variable DOMAINNAME not set}
        - traefik.enable=true
        - traefik.port=8500
        - traefik.tags=${TRAEFIK_PUBLIC_TAG:-traefik-public}
        - traefik.docker.network=traefik_proxy
        - traefik.frontend.entryPoints=http,https
        - traefik.frontend.redirect.entryPoint=https
        - traefik.frontend.auth.forward.address=http://oauth:4181
        - traefik.frontend.auth.forward.authResponseHeaders=X-Forwarded-User
        - traefik.frontend.auth.forward.trustForwardHeader=true
  consul-replica:
    image: consul
    command: agent -server -client=0.0.0.0 -retry-join="consul-leader"
    volumes:
      - consul-data-replica:/consul/data
    environment:
      - CONSUL_BIND_INTERFACE=eth0
      - 'CONSUL_LOCAL_CONFIG={"leave_on_terminate": true}'
    networks:
      - traefik_proxy
    deploy:
      replicas: ${CONSUL_REPLICAS:-3}
      placement:
        preferences:
          - spread: node.id

  traefik:
    image: traefik:v1.7
    hostname: traefik
    restart: always
    networks:
      - traefik_proxy
    ports:
      - target: 80
        published: 80
      - target: 443
        published: 443
      - target: 8080
        published: 8145
    deploy:
      replicas: ${TRAEFIK_REPLICAS:-3}
      placement:
        constraints:
          - node.role == manager
        preferences:
          - spread: node.id
      labels:
        traefik.enable: 'true'
        traefik.backend: traefik
        traefik.protocol: http
        traefik.port: 8080
        traefik.tags: traefik-public
        traefik.frontend.rule: Host:traefik.${DOMAINNAME}
        traefik.frontend.headers.SSLHost: traefik.${DOMAINNAME}
        traefik.docker.network: traefik_proxy
        traefik.frontend.passHostHeader: 'true'
        traefik.frontend.headers.SSLForceHost: 'true'
        traefik.frontend.headers.SSLRedirect: 'true'
        traefik.frontend.headers.browserXSSFilter: 'true'
        traefik.frontend.headers.contentTypeNosniff: 'true'
        traefik.frontend.headers.forceSTSHeader: 'true'
        traefik.frontend.headers.STSSeconds: 315360000
        traefik.frontend.headers.STSIncludeSubdomains: 'true'
        traefik.frontend.headers.STSPreload: 'true'
        traefik.frontend.headers.customResponseHeaders: X-Robots-Tag:noindex,nofollow,nosnippet,noarchive,notranslate,noimageindex
        traefik.frontend.headers.customFrameOptionsValue: 'allow-from https:${DOMAINNAME}'
        traefik.frontend.auth.forward.address: 'http://oauth:4181'
        traefik.frontend.auth.forward.authResponseHeaders: X-Forwarded-User
        traefik.frontend.auth.forward.trustForwardHeader: 'true'
    domainname: ${DOMAINNAME}
    dns:
      - 1.1.1.1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ${USERDIR}/docker/traefik:/etc/traefik
      - ${USERDIR}/docker/shared:/shared
    environment:
      CF_API_EMAIL: ${CLOUDFLARE_EMAIL}
      CF_API_KEY: ${CLOUDFLARE_API_KEY}
    command:
      #- "storeconfig" #This is the push to consul, secondary traefik must be created and interfaced to this traefik. Remove this traefik's open ports, it shuts down once consul is messaged.
      - '--logLevel=INFO'
      - '--InsecureSkipVerify=true' #for unifi controller to not throw internal server error message
      - '--api'
      - '--api.entrypoint=apiport'
      - '--defaultentrypoints=http,https'
      - '--entrypoints=Name:http Address::80 Redirect.EntryPoint:https'
      - '--entrypoints=Name:https Address::443 TLS TLS.SniStrict:true TLS.MinVersion:VersionTLS12 CipherSuites:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256'
      - '--entrypoints=Name:apiport Address::8080'
      - '--file'
      - '--file.directory=/etc/traefik/rules/'
      - '--file.watch=true'
      - '--acme'
      - '--acme.storage=/etc/traefik/acme/acme.json'
      - '--acme.entryPoint=https'
      # not yet ready?
      #      - "--acme.TLS-ALPN-01=true"
      - '--acme.dnsChallenge=true'
      - '--acme.dnsChallenge.provider=cloudflare'
      - '--acme.dnsChallenge.delayBeforeCheck=60'
      - '--acme.dnsChallenge.resolvers=1.1.1.1,1.0.0.1'
      - '--acme.onHostRule=true'
      - '--acme.email=admin@${DOMAINNAME}'
      - '--acme.acmeLogging=true'
      - '--acme.domains=${DOMAINNAME},*.${DOMAINNAME},'
      - '--acme.KeyType=RSA4096'
      #Let's Encrypt's staging server,
      #caServer = "https://acme-staging-v02.api.letsencrypt.org/directory"
      - '--docker'
      - '--docker.swarmMode'
      - '--docker.domain=${DOMAINNAME}'
      - '--docker.watch'
      - '--docker.exposedbydefault=false'
      #- "--consul"
      #- "--consul.endpoint=consul:8500"
      #- "--consul.prefix=traefik"
      - '--retry'
      - 'resolvers=[192,168.1.1:53,1.1.1.1:53,]'
    depends_on:
      - consul-leader

docker-compose.media.yml -‘码头组成’

代码语言:javascript
运行
复制
  sabnzbd:
    image: linuxserver/sabnzbd
    container_name: sabnzbd
    restart: always
    network_mode: service:transmission-vpn
    # depends_on:
    #  - transmission-vpn
    #   ports:
    #      - '${SABNZBD_PORT}:8080'
    volumes:
      - ${USERDIR}/docker/sabnzbd:/config
      - /media/Data/Downloads:/Downloads
    #      - ${USERDIR}/Downloads/incomplete:/incomplete-downloads
    environment:
      PUID: ${PUID}
      PGID: ${PGID}
      TZ: ${TZ}
      UMASK_SET: 002
    deploy:
      replicas: 1
      labels:
        traefik.enable: 'true'
        traefik.backend: sabnzbd
        traefik.protocol: http
        traefik.port: 8080
        traefik.tags: traefik_proxy
        traefik.frontend.rule: Host:sabnzbd.${DOMAINNAME}
        #     traefik.frontend.rule: Host:${DOMAINNAME}; PathPrefix: /sabnzbd
        traefik.frontend.headers.SSLHost: sabnzbd.${DOMAINNAME}
        traefik.docker.network: traefik_proxy
        traefik.frontend.passHostHeader: 'true'
        traefik.frontend.headers.SSLForceHost: 'true'
        traefik.frontend.headers.SSLRedirect: 'true'
        traefik.frontend.headers.browserXSSFilter: 'true'
        traefik.frontend.headers.contentTypeNosniff: 'true'
        traefik.frontend.headers.forceSTSHeader: 'true'
        traefik.frontend.headers.STSSeconds: 315360000
        traefik.frontend.headers.STSIncludeSubdomains: 'true'
        traefik.frontend.headers.STSPreload: 'true'
        traefik.frontend.headers.customResponseHeaders: X-Robots-Tag:noindex,nofollow,nosnippet,noarchive,notranslate,noimageindex
        #      traefik.frontend.headers.frameDeny: "true" #customFrameOptionsValue overrides this
        traefik.frontend.headers.customFrameOptionsValue: 'allow-from https:${DOMAINNAME}'
        traefik.frontend.auth.forward.address: 'http://oauth:4181'
        traefik.frontend.auth.forward.authResponseHeaders: X-Forwarded-User
        traefik.frontend.auth.forward.trustForwardHeader: 'true'

我已经尝试过多种方法,比如删除deploy命令,只使用标签等,但这一点都没有帮助。我的Traefik日志也没有显示出任何可能说出问题所在的东西。

EN

回答 1

Stack Overflow用户

发布于 2020-05-15 04:03:29

您是否正在运行de .env文件来设置环境变量?因为停靠库堆栈当前不支持特性.env。在运行docker堆栈之前,必须手动获取运行导出$(cat .env)的.env。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61807129

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档