I’ve set up GitLab using Docker and Traefik 2.11 as a reverse proxy, but when I try to access GitLab at https://gitlab.example.com, I get a 404 error. I’m using Docker Compose for both Traefik and GitLab configurations. Traefik is supposed to handle HTTPS requests and route them to GitLab, but it seems like the routing isn’t working as expected.
version: '3'
services:
traefik:
image: traefik:v2.11
container_name: "traefik"
restart: always
command:
- "--api.insecure=true"
- "--providers.docker"
- "--providers.docker.exposedByDefault=false"
- "--providers.docker.network=traefik_web"
- "--entrypoints.http.address=:80"
- "--entrypoints.http.http.redirections.entrypoint.to=https"
- "--entrypoints.http.http.redirections.entrypoint.scheme=https"
- "--entrypoints.https.address=:443"
- "--entrypoints.https.http.tls.certResolver=le"
- "--certificatesresolvers.le.acme.tlschallenge=true"
- "[email protected]"
- "--certificatesresolvers.le.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./../letsencrypt:/letsencrypt
networks:
- web
networks:
web:
name: traefik_web
version: '3.7'
services:
gitlab-main:
image: 'gitlab/gitlab-ce:latest'
hostname: "gitlab.skull-music.com"
container_name: gitlab
environment:
GITLAB_OMNIBUS_CONFIG: |
external_url 'https://gitlab.skull-music.com'
networks:
- traefik_web
labels:
labels:
- "traefik.enable=true"
- "traefik.http.routers.gitlab.rule=Host(`gitlab.skull-music.com`)"
- "traefik.http.routers.gitlab.entrypoints=https"
- "traefik.http.routers.gitlab.tls=true"
- "traefik.http.routers.gitlab.service=gitlab-main"
- "traefik.http.services.gitlab-main.loadbalancer.server.port=80"
- "traefik.http.routers.gitlab.tls.certResolver=le"
networks:
traefik_web:
name: traefik_web
external: true
What I’ve tried:
- Ensuring DNS settings are correct.
- Checking Traefik and GitLab logs, but there are no obvious errors related to the 404.
- Verifying that the Traefik network
traefik_web
is correctly shared between Traefik and GitLab services. - I added the line like suggested in the answers.
- "traefik.http.routers.gitlab.tls.certResolver=le"
Questions:
Is there any misconfiguration in my Docker Compose files that could be causing this issue?
How can I further debug the 404 error when accessing GitLab through Traefik?
Any help or pointers would be greatly appreciated. Thank you!
2
Answers
Adding the lines nginx['listen_https'] = false and nginx['listen_port'] = 80 to the docker-copmpose.yml file effectively resolved my issue.
Without it the container stopped working after some time do to a RuntimeError related to acme_certificate.
Also i want mention that gitlab takes a while to start (in the case till it crashed 10 minutes)
I think you are missing a
certResolver
from your service labels. You have this on your traefik command, but it needs to be included on thegitlab-main
service too, like this:From Traefik Documentation
I tested on my own server, and without it I get the same
404
error.