Docker Community Forums

Share and learn in the Docker community.

Two Swarm Services behind traefik with same host rule and different Path (one not accessible)

I am working with a small docker swarm of three nodes (1 manager, 2 workers). I am usinf traefik as a reverse proxy to give users access to all the services in my swarm (currently registry, visualizer and two jenkins services). I am using Host Frontend rules to access my services.
Example for visualizer service (from visualizer.yml):

- "traefik.frontend.rule=Host:visualizer.server.domain.de"

With this I can access my visualizer service via browser on https://visualizer.server.domain.de
This setup worked for all my services until now. Yesterday I added a second jenkins service to my jenkins stack, because we want to provide an own jenkins service for every development project. My two jenkins services are named:

  • jenkins-ci-foo
  • jenkins-ci-bar

I started with only jenkins-ci-foo in my jenkins.yml and I could access this jenkins service via browser on https://jenkins.server.domain.de/jenkins-ci-foo
Then I added the second service jenkins-ci-bar to my jenkins.yml file. I expected that I can access jenkins-ci-foo on https://jenkins.server.domain.de/jenkins-ci-foo and jenkins-ci-bar on https://jenkins.server.domain.de/jenkins-ci-bar. But After re-deploying my jenkins stack, only jenkins-ci-bar is accessible and trying to access jenkins-ci-foo gives me HTTP 404 page not found error.
When I do docker stack ps jenkins, I can see that both services are running:

ID           NAME                      IMAGE                  NODE     DESIRED STATE
zkdq81zavsk7 jenkins_jenkins-ci-foo.1  jenkins/jenkins:2.184  worker2  Running  ...
6ehji12cr06i jenkins_jenkins-ci-bar.1  jenkins/jenkins:2.184  worker2  Running  ...

I do not understand…

  • … why I can only access one of my two jenkins services
    … why I can access the second service I added (jenkins-ci-bar) but not the first one (jenkins-ci-foo)
    … why the first one (jenkins-ci-foo) worked, until I added the second one (jenkins-ci-bar)

My jenkins.yml file looks as follows:

version: "3.7"

services:
    jenkins-ci-foo:
        image: jenkins/jenkins:2.184
        environment:
            - JENKINS_OPTS=--httpPort=8082 --prefix=/jenkins-ci-foo
        networks:
            - devops-net
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
        deploy:
            placement:
                constraints:
                    - node.role == worker
            labels:
                - "traefik.enable=true"
                - "traefik.port=8082"
                - "traefik.frontend.rule=Host:jenkins.server.domain.de,PathPrefix:/jenkins-ci-foo"
                - "traefik.backend=jenkins-ci-foo"
                - "traefik.docker.network=devops-net"
    jenkins-ci-bar:
        image: jenkins/jenkins:2.184
        environment:
            - JENKINS_OPTS=--httpPort=8083 --prefix=/jenkins-ci-bar
        networks:
            - devops-net
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock
        deploy:
            placement:
                constraints:
                    - node.role == worker
            labels:
                - "traefik.enable=true"
                - "traefik.port=8083"
                - "traefik.frontend.rule=Host:jenkins.server.domain.de,PathPrefix:/jenkins-ci-bar"
                - "traefik.backend=jenkins-ci-bar"
                - "traefik.docker.network=devops-net"


networks:
        devops-net:
                external: true

I am not sure what I am doing wrong. I checked the logs of both services with docker service logs but both jenkins services started:

docker service logs jenkins_jenkins-ci-foo
jenkins_jenkins-ci-foo.1.zkdq81zavsk7@worker2    | 2019-07-16 07:20:16.319+0000 [id=20]   INFO    hudson.WebAppMain$3#run: Jenkins is fully up and running
docker service logs jenkins_jenkins-ci-bar
jenkins_jenkins-ci-bar.1.6ehji12cr06i@worker2    | 2019-07-16 07:03:36.259+0000 [id=20]   INFO    hudson.WebAppMain$3#run: Jenkins is fully up and running

I would be really happy, if someone can have a look at this.
Kind regards
Timo

I just found the mistake about 5 minutes after writing the topic -.-
I separated my Frontend rules with comma “,” and not with semicolon “;”. After changing to semicolon, both services are accessible as expected.
Just in case anyone else has this problem.