Docker:Gitlab 无法在 Traefik 后面运行:502 错误网关

Docker:Gitlab 无法在 Traefik 后面运行:502 错误网关

我在这里发帖,因为我正在寻找在 Traefik 反向代理的帮助下自行托管我的个人网站(wordpress)和其他项目的源代码(gitlab 实例)。

目前,当我尝试访问以下不同的软件时:

  • (https://)traefik.mydomain.com :Traefik 的仪表板,没问题
  • (https://)www.mydomain.com:我的wordpress网站,还可以。

但是,当我尝试访问时:

  • (https://)gitlab.mydomain.com:Gitlab 的 webUI,我遇到了错误:502错误的网关。

但是经过多次尝试后,如果我在安装结束后或几分钟后(平均 15 分钟)再次访问 gitlab webUI,我会出现相同的错误:502 错误网关。

如果有人有想法,能帮助我吗?

这是我的配置文件(docker-compose.yml):

    version: "3.7"
    services:
      traefik:
        image: "traefik:latest"
        container_name: "traefik"
        hostname: traefik.mydomain.com
        restart: always
        networks:
          - webgateway
        ports:
      - "80:80"
      - "443:443"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - /srv/labs/traefik/traefik.toml:/etc/traefik/traefik.toml:ro
      - /srv/labs/traefik/acme.json:/acme.json
      - /srv/labs/traefik/traefik_dynamic.toml:/etc/traefik/traefik_dynamic.toml:ro
    labels:
      # http
      traefik.enable: "true"
      traefik.http.routers.traefik.rule: "Host(`traefik.mydomain.com`)"
      traefik.http.routers.traefik.entrypoints: "web"
      traefik.http.routers.traefik.service: "api@internal"
      # https
      traefik.http.middlewares.https-redirect.redirectscheme.scheme: "https"
      traefik.http.middlewares.https-redirect.redirectscheme.permanent: "true"
      traefik.http.routers.traefik.middlewares: "https-redirect@docker"

      traefik.http.routers.traefik-https.entrypoints: "websecure"
      traefik.http.routers.traefik-https.rule: "Host(`traefik.mydomain.com`)"
      traefik.http.routers.traefik-https.tls: "true"
      traefik.http.routers.traefik-https.tls.certresolver: "letsencrypt"

      traefik.http.routers.traefik-https.middlewares: "dashboard-auth,security@file, compression@file"
      # traefik dashboard auth
      traefik.http.routers.traefik.middlewares: "dashboard-auth"
      # traefik dashboard credentials
      traefik.http.middlewares.dashboard-auth.basicauth.users: "login:$$apr1$$XFLC8oLD$$tufQCjkmmNkXfL.cm96E90"

  db:
    container_name: mariadb
    hostname: bdd.mydomain.com
    image: mariadb:latest
    networks:
      - wp
    volumes:
      - wp_db/:/var/lib/mysql/
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: oC1rieph
      MYSQL_DATABASE: wordpress
      MYSQL_USER: wordpress
      MYSQL_PASSWORD: oC1rieph

  website:
    depends_on:
      - db
    container_name: "wordpress"
    hostname: www.mydomain.com
    image: wordpress:latest
    networks:
      - wp
      - webgateway
    ports:
      - 8000:80
    volumes:
      - wp_statics:/var/www/html/

    restart: always
    environment:
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: wordpress
      WORDPRESS_DB_PASSWORD: oC1rieph

    labels:
      traefik.enable: "true"
      traefik.http.routers.website.rule: "Host(`www.mydomain.com`)"
      traefik.http.routers.website.entrypoints: "web"

      traefik.http.middlewares.https-redirect.redirectscheme.scheme: "https"
      traefik.http.middlewares.https-redirect.redirectscheme.permanent: "true"
      traefik.http.routers.website.middlewares: "https-redirect@docker"

      traefik.http.routers.website-https.entrypoints: "websecure"
      traefik.http.routers.website-https.rule: "Host(`www.mydomain.com`)"
      traefik.http.routers.website-https.tls: "true"
      traefik.http.routers.website-https.tls.certresolver: "letsencrypt"
      traefik.http.routers.website-https.middlewares: "security@file, compression@file"

  gitlab:
    container_name: "gitlab"
    hostname: 'gitlab.mydomain.com'
    image: 'gitlab/gitlab-ce:latest'
    restart: always
    networks:
      - webgateway
    ports:
      - '2200:22'

      environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://gitlab.mydomain.com'
        gitlab_rails['gitlab_shell_ssh_port'] = 2200

    volumes:
      - '/srv/gitlab/config:/etc/gitlab:Z'
      - '/srv/gitlab/logs:/var/log/gitlab:Z'
      - '/srv/gitlab/data:/var/opt/gitlab:Z'
      - '/etc/localtime:/etc/localtime:ro'

    labels:
      traefik.enable: "true"
      traefik.http.routers.gitlab-https.entrypoints: "websecure"
      traefik.http.routers.gitlab-https.rule: "Host(`gitlab.mydomain.com`)"
      traefik.http.routers.gitlab-https.tls: "true"
      traefik.http.routers.gitlab-https.tls.certresolver: "letsencrypt"
      traefik.http.routers.gitlab-https.middlewares: "security@file, compression@file"
      traefik.http.routers.gitlab.rule: "Host(`gitlab.mydomain.com`)"
      traefik.http.routers.gitlab.entrypoints: "websecure"
      traefik.http.routers.gitlab.tls.certresolver: "letsencrypt"
      traefik.http.routers.gitlab.middlewares: "gitlab-headers"
      traefik.http.routers.gitlab.service: "gitlab"
      traefik.http.middlewares.gitlab-headers.headers.customrequestheaders.X_FORWARDED_PROTO: "https"
      traefik.http.middlewares.gitlab-headers.headers.customrequestheaders.X_Forwarded-Ssl=: "on"
      traefik.http.middlewares.gitlab-headers.headers.customresponseheaders.X_FORWARDED_PROTO: "https"
      traefik.http.middlewares.gitlab-headers.headers.customresponseheaders.X_Forwarded-Ssl: "on"
      traefik.http.services.gitlab.loadbalancer.server.port: "80"

      traefik.http.routers.gitlab-registry.rule: "Host(`gitlab-registry.mydomain.com`)"
      traefik.http.routers.gitlab-registry.entrypoints: "websecure"
      traefik.http.routers.gitlab-registry.tls.certresolver: "letsencrypt"
      traefik.http.routers.gitlab-registry.service: "gitlab-registry"
      traefik.http.services.gitlab-registry.loadbalancer.server.port: "5000"
    cap_add:
      - SYS_ADMIN


networks:
  wp:
  webgateway:
  #webmail:
    driver: bridge

volumes:
  wp_db:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: /srv/mysql

  wp_statics:
    driver: local
    driver_opts:
      o: bind
      type: none
      device: /srv/wordpress/www

这是我的硬件配置:

  • 操作系统:Debian 10 x64
  • 中央处理器:英特尔赛扬 N3450
  • 内存:4G DDR3
  • 存储:SDD 128Go
  • 网络:平均300Mbps

相关内容