Docker Gitlab doesnt work with traefik proxy

Hi
I tried to add gitlab.localhost domain to gitlab. My other services - whoami, jenkins, artifactory work well, but gitlab doesnt. Container is up but Im getting “internal server error”. I tried many different things from google but it just doesnt work with gitlab.localhost domain. But offcourse with default setup (localhost.8929) works well.

version: '3.1'

networks:
  dominiknet:
    driver: bridge

services:
  traefik-main:
    image: "traefik:v2.0.0-rc3"
    container_name: "traefik"
    command:
      # - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.web.address=:80"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    networks: 
      - dominiknet      

# https://github.com/jenkinsci/docker/blob/master/README.md 
  jenkins-main:
    image: 'jenkins/jenkins:lts'
    container_name: jenkins-master
    #restart: always
    ports:
      # - 8180:8080
      - 50000:50000
    volumes:
      - ./volumes/jenkins/master:/var/jenkins_home
    networks: 
      - dominiknet
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.jenkinsmaster.rule=Host(`jenkins.localhost`)"


  gitlab-main:
    image: 'gitlab/gitlab-ce:latest'
    container_name: gitlab.localhost
    hostname: 'gitlab.localhost'
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        #  external_url 'http://localhost:8929'
        external_url 'http://gitlab.localhost'
        gitlab_rails['gitlab_shell_ssh_port'] = 2224
        # nginx['listen_port'] = 80
        # nginx['listen_https'] = false
        # nginx['proxy_set_headers'] = {
        #   "X-Forwarded-Proto" => "https",
        #   "X-Forwarded-Ssl" => "on"
        # }
    ports:
      - '8929:8929'
      - '2224:22'
    volumes:
      - './volumes/gitlab/config:/etc/gitlab'
      - './volumes/gitlab/logs:/var/log/gitlab'
      - './volumes/gitlab/data:/var/opt/gitlab'
    networks:
      - dominiknet
    labels:
      - "traefik.enable=true"
      # - "traefik.frontend.rule=Host:gitlab.localhost"
      # - "traefik.port=80"
      # - "traefik.backend=gitlab"
      # - "traefik.frontend.entryPoints=http,https"
      # - "traefik.docker.network=traefik"
      - "traefik.http.routers.gitlab.rule=Host(`gitlab.localhost`)"
      # - "traefik.port=80"
      # - "traefik.http.services.gitlabmain.loadbalancer.server.port=8929"  
      # - "traefik.docker.network=dominiknet"

# https://www.jfrog.com/confluence/display/RTF/Installing+with+Docker
  artifactory:
    image: docker.bintray.io/jfrog/artifactory-oss:6.16.0
    container_name: artifactory
    #user: "1030:1030"
    ports:
     - 8030:8081
    volumes:
     - ./volumes/artifactory:/var/opt/jfrog/artifactory
#    Add extra Java options by uncommenting the following lines
#    environment:
#     - EXTRA_JAVA_OPTIONS=-Xms512m -Xmx4g
    ulimits:
      nproc: 65535
      nofile:
        soft: 32000
        hard: 40000
    networks:
      - dominiknet
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.artifactory.rule=Host(`artifactory.localhost`)"

  whoami:
    # A container that exposes an API to show its IP address
    image: containous/whoami
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
    networks:
      - dominiknet

Seriously? No one will help?

I see you went from traefik 1.x to traefik 2.x and just commented out the old labels.
With traefik 2, the gitlab config is missing some labels (entrypoint, service and service port)

labels:
      - "traefik.enable=true"
      - "traefik.http.routers.gitlab.entrypoints=http"
      - "traefik.http.routers.gitlab.rule=Host(`gitlab.localhost`)"
      - "traefik.http.routers.gitlab.service=gitlab"
      - "traefik.http.services.gitlab.loadbalancer.server.port=80"

@yacinelazaar With your settings im getting 404.

https://pastebin.com/v5Q6HBX8

Your traefik entrypoint should be the same as configured with gitlab

  • “–entrypoints.web.address=:80” >> - “–entrypoints.http.address=:80”

Also im assuming you added the gitlab url as alias in /etc/hosts

Bad gateway now.

https://pastebin.com/J1rdWnEV

No i didnt anything there but as i previously said, 3 other services from this file work ok.

You mean Jenkins, Artifact and whomai are working fine?
Could you wait for gitlab to initialize?
Can you paste the modified setup?

can you uncomment this line

# nginx['listen_port'] = 80

version: '3.1'

networks:
  dominiknet:
driver: bridge

services:
  traefik-main:
image: "traefik:v2.0.0-rc3"
container_name: "traefik"
command:
  # - "--log.level=DEBUG"
  - "--api.insecure=true"
  - "--providers.docker=true"
  - "--providers.docker.exposedbydefault=false"
  - "--entrypoints.http.address=:80"
ports:
  - "80:80"
  - "8080:8080"
volumes:
  - "/var/run/docker.sock:/var/run/docker.sock:ro"
networks: 
  - dominiknet      

# https://github.com/jenkinsci/docker/blob/master/README.md 
  jenkins-main:
image: 'jenkins/jenkins:lts'
container_name: jenkins-master
#restart: always
ports:
  # - 8180:8080
  - 50000:50000
volumes:
  - ./volumes/jenkins/master:/var/jenkins_home
networks: 
  - dominiknet
labels:
  - "traefik.enable=true"
#   - "traefik.docker.network=dominiknet"
  - "traefik.http.routers.jenkinsmaster.rule=Host(`jenkins.localhost`)"

#https://hub.docker.com/r/jenkins/jnlp-slave/
  jenkins-main-slave:
image: 'jenkins/jnlp-slave'
container_name: jenkins-slave1
#restart: always
environment:
  - 'JENKINS_URL=http://jenkins-master:8080'
  - 'JENKINS_SECRET=1c21487493a01aac757486af3e2120202c73534547a59eb57c4c50ec71749818'
  - 'JENKINS_AGENT_NAME=jenkins-slave1'
volumes:
  - './volumes/jenkins/slave1:/home/jenkins'
depends_on:
  - jenkins-main
networks:
  - dominiknet

# https://docs.gitlab.com/omnibus/docker/#install-gitlab-using-docker-compose
  #  external_url 'http://localhost:8929'
  gitlab-main:
image: 'gitlab/gitlab-ce:latest'
container_name: gitlab-main
#restart: always
#hostname: 'gitlab.localhost'
environment:
  GITLAB_OMNIBUS_CONFIG: |
    external_url 'http://localhost:8929'
    gitlab_rails['gitlab_shell_ssh_port'] = 2224
    nginx['listen_port'] = 80
    # nginx['listen_https'] = false
    # nginx['proxy_set_headers'] = {
    #   "X-Forwarded-Proto" => "https",
    #   "X-Forwarded-Ssl" => "on"
    # }
ports:
  - '8929:8929'
  - '2224:22'
volumes:
  - './volumes/gitlab/config:/etc/gitlab'
  - './volumes/gitlab/logs:/var/log/gitlab'
  - './volumes/gitlab/data:/var/opt/gitlab'
networks:
  - dominiknet
labels:
labels:
  - "traefik.enable=true"
  - "traefik.http.routers.gitlab.entrypoints=http"
  - "traefik.http.routers.gitlab.rule=Host(`gitlab.localhost`)"
  - "traefik.http.routers.gitlab.service=gitlab"
  - "traefik.http.services.gitlab.loadbalancer.server.port=80"

# https://www.jfrog.com/confluence/display/RTF/Installing+with+Docker
  artifactory:
image: docker.bintray.io/jfrog/artifactory-oss:6.16.0
container_name: artifactory
#user: "1030:1030"
ports:
 - 8030:8081
volumes:
 - ./volumes/artifactory:/var/opt/jfrog/artifactory
#    Add extra Java options by uncommenting the following lines
#    environment:
#     - EXTRA_JAVA_OPTIONS=-Xms512m -Xmx4g
#restart: always
ulimits:
  nproc: 65535
  nofile:
    soft: 32000
    hard: 40000
networks:
  - dominiknet
labels:
  - "traefik.enable=true"
#   - "traefik.docker.network=dominiknet"
  - "traefik.http.routers.artifactory.rule=Host(`artifactory.localhost`)"

  whoami:
# A container that exposes an API to show its IP address
image: containous/whoami
labels:
  - "traefik.enable=true"
  - "traefik.http.routers.whoami.rule=Host(`whoami.docker.localhost`)"
  #- "traefik.docker.network=dominiknet"
networks:
  - dominiknet

I strongly suggest you to run it by yourself.

Why did you change the external URL?

This works.
Adpat to your needs.


version: '3.5'

services:

  traefik-main:
    image: "traefik:v2.0.0-rc3"
    container_name: "traefik-main"
    networks: 
      - dominiknet
    command:
      - "--log.level=DEBUG"
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--entrypoints.http.address=:80"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
         


  gitlab-main:
    image: 'gitlab/gitlab-ce:latest'
    container_name: gitlab-main
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://gitlab.localhost'
        nginx['listen_port'] = 80
    networks:
      - dominiknet
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.gitlab.entrypoints=http"
      - "traefik.http.routers.gitlab.rule=Host(`gitlab.localhost`)"
      - "traefik.http.routers.gitlab.service=gitlab"
      - "traefik.http.services.gitlab.loadbalancer.server.port=80"

networks:
  dominiknet:
    driver: bridge
2 Likes

Yep! It worked! Thank you VERY much @yacinelazaar !!!