首页 文章

Traefik Bad Gateway

提问于
浏览
1

我有一些奇怪的问题 . 我有以下设置:一个docker-host运行traefik作为LB服务多个站点 . 网站是大多数php / apache . HTTPS由traefik管理 . 每个站点都使用包含以下内容的docker-compose YAML启动:

version: '2.3'
services:
  redis:
    image: redis:alpine
    container_name: ${PROJECT}-redis
    networks:
      - internal
  php:
    image: registry.gitlab.com/OUR_NAMESPACE/docker/php:${PHP_IMAGE_TAG}
    environment:
      - APACHE_DOCUMENT_ROOT=${APACHE_DOCUMENT_ROOT}
    container_name: ${PROJECT}-php-fpm
    volumes:
       - ${PROJECT_PATH}:/var/www/html:cached
       - .docker/php/php-ini-overrides.ini:/usr/local/etc/php/conf.d/99-overrides.ini
    ports:
      - 80
    networks:
      - proxy
      - internal
    labels:
      - traefik.enable=true
      - traefik.port=80
      - traefik.frontend.headers.SSLRedirect=false
      - traefik.frontend.rule=Host:${PROJECT}
      - "traefik.docker.network=proxy"

networks:
  proxy:
    external:
      name: proxy
  internal:

(作为PHP,我们使用5.6.33-apache-jessie或7.1.12-apache f.e.)

除此之外,一些网站获得以下标签:

traefik.docker.network=proxy
traefik.enable=true
traefik.frontend.headers.SSLRedirect=true
traefik.frontend.rule=Host:example.com, www.example.com
traefik.port=80
traefik.protocol=http

我们得到的是一些请求以502 Bad Gateway traefik调试输出结束显示:

time="2018-03-21T12:20:21Z" level=debug msg="vulcand/oxy/forward/http: Round trip: http://172.18.0.8:80, code: 502, Length: 11, duration: 2.516057159s"

有人可以帮忙吗?当它发生在我们的traefik.toml时它是完全随机的:

debug = true
checkNewVersion = true
logLevel = "DEBUG"

defaultEntryPoints = ["https", "http"]
[accessLog]

[web]
address = ":8080"

[web.auth.digest]
users = ["admin:traefik:some-encoded-pass"]

[entryPoints]
  [entryPoints.http]
  address = ":80"
#    [entryPoints.http.redirect] # had to disable this because HTTPS must be enable manually (not my decission)
#      entryPoint = "https"
  [entryPoints.https]
  address = ":443"
    [entryPoints.https.tls]


[retry]

[docker]
endpoint = "unix:///var/run/docker.sock"
domain = "example.com"
watch = true
exposedbydefault = false


[acme]
email = "info@example.com"
storage = "acme.json"
entryPoint = "https"
onHostRule = true

[acme.httpChallenge]
entryPoint = "http"

问题可能与使用相同的docker-compose.yml有关吗?

2 回答

  • 3

    对于遇到同样问题的人:

    重新创建网络(代理)并重新启动每个站点/容器后,它似乎现在正常工作 . 我仍然不知道问题出在哪里 .

  • 1

    在您的示例中,您没有启用traefik:

    traefik.enable=false
    

    确保先启用它,然后测试容器 .

相关问题