为 Traefik 代理后面的 Mautic 获取 "Gateway Timeout"

Getting "Gateway Timeout" for Mautic behind Traefik proxy

我在 Traefik 反向代理后面部署了一个带有 Mautic 的多容器应用程序。 但是,我收到“网关超时”消息。

反向代理的配置似乎没问题,因为应用程序中的其他容器工作正常。

我也把mautic设置改成了mautics域名

有什么想法吗?

docker-compose.yml

version: '3.3'

services:
  reverse-proxy:
    image: traefik:v2.4
    restart: always
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - ./traefik:/etc/traefik
      - /var/run/docker.sock:/var/run/docker.sock

  mautic-app:
    restart: always
    image: mautic/mautic:v3
    volumes:
      - mautic_data:/var/www/html
    environment:
      - MAUTIC_DB_HOST=mautic-database
      - MAUTIC_DB_USER=${MAUTIC_DB_USER}
      - MAUTIC_DB_PASSWORD=${MAUTIC_DB_PASSWORD}
      - MAUTIC_DB_NAME=mautic3
    ports:
      - 80
    labels:
      - 'traefik.enable=true'
      - 'traefik.http.routers.mautic.tls=true'
      - 'traefik.http.routers.mautic.tls.domains[0].main=optin.${SITE}'
      - 'traefik.http.routers.mautic.tls.certresolver=lets-encrypt'
      - 'traefik.http.routers.mautic.rule=Host(`optin.${SITE}`)'
    depends_on:
      - mautic-database
    networks:
      - mautic-net

  mautic-database:
    image: powertic/percona-docker
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: ${MAUTIC_DB_PASSWORD}
    ports:
      - 3306
    volumes:
      - database:/var/lib/mysql
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --sql-mode=""
    networks:
      - mautic-net

volumes:
  database:
    driver: local
  mautic_data:
    driver: local

networks:
  mautic-net:
    driver: bridge

traefik.toml

[log]
  level = "DEBUG"

[providers]
  [providers.docker]
    exposedByDefault = false
  [providers.file]
    directory = "/etc/traefik/dynamic"

[entryPoints]
  [entryPoints.http]
    address = ":80"
  [entryPoints.https]
    address = ":443"

[certificatesResolvers.lets-encrypt.acme]
  storage = "/etc/traefik/acme.json"
  email = "jenslaufer@jenslaufer.com"
  [certificatesResolvers.lets-encrypt.acme.tlsChallenge]

力-https.toml

[http.routers]
  [http.routers.force-https]
    entryPoints = ["http"]
    middlewares = ["force-https"]
    rule = "HostRegexp(`{any:.+}`)"
    service = "noop"

[http.middlewares]
  [http.middlewares.force-https.redirectScheme]
    scheme = "https"

[http.services]
  [http.services.noop.loadBalancer]

不确定您在代理后面使用的是 Apache 还是 PHP FPM。

但是……Traefik does not support fastCgi Proxy

我们在使用 Traefik 时遇到了这个问题,因此 mautic kubernetes 设置了 nginx-proxy。

这是 docker-compose 中的“错误配置”: Traefik 和 Maurice 在不同的网络中。

将 Traefik 移动到 mautic-net 网络解决了这个问题。

如果您 docker 运行 处于游泳模式,容器将连接多个网络。 Traefik 需要指向要使用的网络。

您必须在后端服务容器上设置标签traefik.docker.network

labels:
   traefik.docker.network: <traefik network>

否则,你有时会成功,但大多数时候 traefik 会 return 网关超时