Can't redirect to custom port container

Hello,

I work on a intranet where I'm testing exposing multiple service through Traefik.
I have Traefik configured to listen to ports 80, 443. TLS is configured.

From now, I used to serve one service only with traefik. But now I want to serve multi service accessible from different domain name and custom certificate for each domain name.

For my first service, I use drawio docker, the exposed port is 8080, I use traefik.yaml to use HTTPS, but it seems the label to use port 8080 of drawio container is not working.

I got error when accessing the drawio URL: 404 page not found

  • traefik docker-compose.yml
version: '3'

services:

  traefik:
   image: traefik:2.11
   healthcheck:
     test:
       - CMD
       - traefik
       - healthcheck
     interval: 10s
     timeout: 5s
     retries: 3
   ports:
     - 80:80
     - 443:443
   volumes:
     - ./traefik.yaml:/etc/traefik/traefik.yaml
     - ./certs/:/certs/
     - /var/run/docker.sock:/var/run/docker.sock
   networks:
      - traefiknet

networks:
  traefiknet:
    external: true
  • traefik.yml
global:
  checkNewVersion: true

log:
  level: WARN
  # level: INFO

api:
  insecure: false
  dashboard: false

ping: {}

providers:
  docker:
    exposedByDefault: false
    watch: true
  file:
    fileName: /etc/traefik/traefik.yaml
    watch: true

entryPoints:
  web:
    address: :80
    # comment out these lins if you don't want to redirect everything
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https
          permanent: true
  websecure:
    address: :443

tls:
  
  certificates:
    - certFile: /certs/drawio.lab.lan-crt.pem
      keyFile: /certs/drawio.lab.lan-key.pem
    - certFile: /certs/gitlab-test.lab.lan-crt.pem
      keyFile: /certs/gitlab-test.lab.lan-key.pem
    - certFile: /certs/nms.lab.lan-crt.pem
      keyFile: /certs/nms.lab.lan-key.pem
    - certFile: /certs/netbox.lab.lan-crt.pem
      keyFile: /certs/netbox.lab.lan-key.pem

My first service (drawio), the container is exposing by default on 8080.

version: '3'

services:

  plantuml-server:
    image: plantuml/plantuml-server
    expose:
      - "8080"
    networks:
      - traefiknet
    volumes:
      - ./fonts:/usr/share/fonts/drawio


  image-export:
    image: jgraph/export-server
    expose:
      - "8000"
    networks:
      - traefiknet
    volumes:
      - ./fonts:/usr/share/fonts/drawio


  drawio:
    image: jgraph/drawio
    depends_on:
      - plantuml-server
      - image-export
    networks:
      - traefiknet
    volumes:
      - ./config/PostConfig.js:/usr/local/tomcat/webapps/draw/js/PostConfig.js
      - ./config/PreConfig.js:/usr/local/tomcat/webapps/draw/js/PreConfig.js
      - ./config/cloud_convert_api_key:/usr/local/tomcat/webapps/draw/WEB-INF/cloud_convert_api_key
      - ./config/google_client_id:/usr/local/tomcat/webapps/draw/WEB-INF/google_client_id
      - ./config/google_client_redirect_uri:/usr/local/tomcat/webapps/draw/WEB-INF/google_client_redirect_uri
      - ./config/google_client_secret:/usr/local/tomcat/webapps/draw/WEB-INF/google_client_secret
      - ./config/msgraph_client_id:/usr/local/tomcat/webapps/draw/WEB-INF/msgraph_client_id
      - ./config/msgraph_client_redirect_uri:/usr/local/tomcat/webapps/draw/WEB-INF/msgraph_client_redirect_uri
      - ./config/msgraph_client_secret:/usr/local/tomcat/webapps/draw/WEB-INF/msgraph_client_secret
    environment:
      - PLANTUML_URL=http://plantuml-server:8080/
      - EXPORT_URL=http://image-export:8000/

    labels:
      - "traefik.enable: true"
      - "traefik.http.routers.drawio.rule=Host(`drawio.lab.lan`)"
      - "traefik.http.routers.drawio.entrypoints=websecure"
      - "traefik.http.routers.drawio.tls=true"
      - "traefik.http.services.drawio.loadbalancer.server.port=8080"

networks:
  traefiknet:
    external: true
  • docker ps show no errors
CONTAINER ID   IMAGE                      COMMAND                  CREATED          STATUS                    PORTS                                                                      NAMES
03a6a5f98a24   jgraph/drawio              "/docker-entrypoint.…"   8 seconds ago    Up 5 seconds              8080/tcp, 8443/tcp                                                         drawio-drawio-1
9da354e97f10   plantuml/plantuml-server   "/entrypoint.sh"         8 seconds ago    Up 6 seconds              8080/tcp                                                                   drawio-plantuml-server-1
c7ea08a64de0   jgraph/export-server       "docker-entrypoint.s…"   8 seconds ago    Up 6 seconds              8000/tcp                                                                   drawio-image-export-1
666f4fabe8e3   traefik:2.11               "/entrypoint.sh trae…"   35 minutes ago   Up 35 minutes (healthy)   0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp   traefik-global-traefik-1

  • Traefik logs display this error but don't get it how to solve this:
traefik-global-traefik-1  | time="2024-02-05T09:44:03Z" level=error msg="Skip container drawio-drawio: field not found, node: enable: true" providerName=docker

Any ideas ?

I found my own issue ! And it was a stupid error

First I needed to change - "traefik.enable: true" to - "traefik.enable=true" in labels. But this was not the main problem.

I changed the network config for my containers.

Initially, I created a network manually by doing docker network create traefiknet and then calling this network as external. BUT there was some problem here because it was not working.

So, for my traefik docker-compose, I added the lines to create automatically a bridge network.

networks:
  traefiknet:
    driver: bridge

On my services docker compose, I repeated the process and also added the traefiknet as external service.

networks:
  drawionet:
    driver: bridge

  traefik-global_traefiknet:
    external: true

Where traefik-global is my folder project name.

I can access my multi service now properly.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.