Traefik show 404 not found for .NET api ruunnig on docker compose

I've issue 404 not found when i access https://example.com/documentrasterizer/api/healthcheck 404 NOT FOUND (in container Work)
but when i access
https://example.com/kibana OK 200
https://example.com/elastic OK 200
https://example.com//rabbitmq OK 200

name: documentrasteriser
services:
  apigateway:
    image: example.com/library/traefik:v3.1
    container_name: ${COMPOSE_PROJECT_NAME}-apigateway
    #build: traefik/conf 
    ports:
      - "8080:8080"  
     # - "443:443"
      #- "80 :80"
      #networks:
      #- documentrasterizer_default
    command:
      - "--entrypoints.web.address=:8080"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--log.level=DEBUG"
      - "--accesslog=true"
      - "--accesslog.format=%[RemoteAddr] - \"%[Request] %[Protocol]\" %status %bytesSent \"%[RequestHeader(Host)]\" %latency" 
    #-  "--entrypoints.websecure.address=:443"
    #  - "--ping"
    #  - "--ping.entrypoint=web" 
   # profiles:
    #        - test-routing
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      # - ./traefik/conf/certs:/etc/ssl/certs
   # healthcheck:
   #  test: ["CMD", "curl", "-f", "http://localhost:8080/ping"]
   #  interval: 30s
   #  timeout: 10s
  #   retries: 3
   #  start_period: 10s
    restart: unless-stopped

  rabbitmq-svc:
    image: example.com/proxy/rabbitmq:3.12.5-management
    container_name: ${COMPOSE_PROJECT_NAME}-rabbitmq
    ports:
      - "5672:5672"
    environment:
      RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER:-bdtemuser}
      RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASSWORD:-bdtem}
      RABBITMQ_DEFAULT_VHOST: ${RABBITMQ_VHOST:-bdtem}
   # networks:
     # - documentrasterizer-network
    #profiles:
    #        - test-routing
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.rabbitmq-ui.rule=Host(`${PROJECT_DOMAINS}`) && PathPrefix(`/rabbitmq`)"   
    # - "project-name=${PROJECT_NAME}"
     #- "traefik.http.routers.${PROJECT_NAME}-rabbitmq-svc.rule=Host(`documentrasteriser.internal`) && PathPrefix(`/rabbitmq`)"
     # - "traefik.http.routers.${PROJECT_NAME}-rabbitmq-svc.tls=true"
     #- "traefik.http.routers.${PROJECT_NAME}-rabbitmq-svc-unsecure.middlewares=redirect-to-https@file"
      - "traefik.http.routers.rabbitmq-ui.entrypoints=web"
      - "traefik.http.services.rabbitmq-ui.loadbalancer.server.port=15672"
      - "traefik.http.middlewares.rabbitmq-strip.stripprefix.prefixes=/rabbitmq"
      - "traefik.http.routers.rabbitmq-ui.middlewares=rabbitmq-strip"
    healthcheck:
      test: ["CMD", "rabbitmq-diagnostics", "status"]
      interval: 30s
      timeout: 10s
      retries: 5
    restart: unless-stopped

  doc-api:
    #build:
     # context: ./services/document-rasterizer-api
     # dockerfile: Dockerfile-api
    image: example.com/document-rasterizer-api:${VERSION:-latest}
    container_name: ${COMPOSE_PROJECT_NAME}-api
    #profiles:
    #        - test-routing
    depends_on:
      rabbitmq-svc:
        condition: service_healthy
      elasticsearch:
        condition: service_healthy
    environment:
      FileStorageConfiguration__WorkingDirectory: /mnt/cifs
      RabbitMqConfiguration__Username: ${RABBITMQ_USER:-bdtemuser}
      RabbitMqConfiguration__Password: ${RABBITMQ_PASSWORD:-bdtem}
      RabbitMqConfiguration__Host: rabbitmq-svc
      RabbitMqConfiguration__VirtualHost: ${RABBITMQ_VHOST:-bdtem}
      ASPNETCORE_URLS: ${URL_HTTP:-http://[::]:81}
      ElasticsearchHealthCheck__Uri: http://elasticsearch:9200
      LOG_PATH: /var/log/tessiemail-document-rasterizer-api
      ES_URI: http://elasticsearch:9200
    volumes:
      - ${MOUNT_CIFS_DIR}:/mnt/cifs
   # networks:
    #   - documentrasterizer-network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.document-api.rule=Host(`${PROJECT_DOMAINS}`) && PathPrefix(`/documentrasterizer`)"
      
        # - "traefik.http.routers.document-naked.rule=PathPrefix(`/documentrasterizer`)"
      - "traefik.http.routers.document-api.entrypoints=web"
      - "traefik.http.services.document-api.loadbalancer.server.port=81"
      - "traefik.http.middlewares.api-strip.stripprefix.prefixes=/documentrasterizer"
      - "traefik.http.routers.document-api.middlewares=api-strip"
      - "traefik.http.middlewares.api-strip-replace.replacepathregex.regex=^/documentrasterizer/?(.*)"
      - "traefik.http.middlewares.api-strip-replace.replacepathregex.replacement=/$${1}"
      - "traefik.http.routers.document-api.middlewares=api-strip,api-strip-replace"
    healthcheck:
      test: >
                  bash -c 'curl -s http://localhost:81/api/healthcheck | grep -q "\"status\":\"Healthy\""' 
      interval: 30s
      timeout: 5s
      retries: 3
      start_period: 10s
    logging:
      driver: gelf
      options:
        gelf-address: udp://127.0.0.1:12201
        tag: "document-rasterizer-api"
        mode: non-blocking
        max-buffer-size: "5m"
    restart: unless-stopped

  worker:
   #  build:
   #    context: ./services/document-rasterizer-worker
   #    dockerfile: Dockerfile-worker
    image: example.com/document-rasterizer-worker:${VERSION:-latest}
    container_name: ${COMPOSE_PROJECT_NAME}-worker
    depends_on:
      rabbitmq-svc:
        condition: service_healthy
    environment:
      QueueConfiguration__Uri: amqp://${RABBITMQ_USER:-bdtemuser}:${RABBITMQ_PASSWORD:-bdtem}@rabbitmq-svc:5672/${RABBITMQ_VHOST:-bdtem}
    volumes:
      - ${MOUNT_CIFS_DIR}:/mnt/cifs
   # networks:
   #   - documentrasterizer-network
    logging:
      driver: gelf
      options:
        gelf-address: udp://127.0.0.1:12201
        tag: "document-rasterizer-worker"
        mode: non-blocking
        max-buffer-size: "5m"
    restart: unless-stopped

  elasticsearch:
    image: example.com/elasticsearch:8.9.1
    container_name: ${COMPOSE_PROJECT_NAME}-elasticsearch
    ports:
      - "9200:9200"
    environment:
      - http.host=0.0.0.0
      - discovery.type=single-node
      - ES_JAVA_OPTS=-Xms512m -Xmx512m
      - xpack.security.enabled=false
      - bootstrap.memory_lock=true
      - xpack.security.http.ssl.enabled=false
      - ELASTIC_USERNAME=${ELASTIC_USERNAME:-bdtemuser} 
      - ELASTIC_PASSWORD=${ELASTIC_PASSWORD:-bdtemuser}
    volumes:
      - ${ELK_DATA}:/usr/share/elasticsearch/data
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.elasticsearch.rule=Host(`${PROJECT_DOMAINS}`) && PathPrefix(`/elastic`)"
      - "traefik.http.routers.elasticsearch.entrypoints=web"
      - "traefik.http.services.elasticsearch.loadbalancer.server.port=9200"
      - "traefik.http.middlewares.elasticsearch-stripprefix.stripprefix.prefixes=/elastic"
      - "traefik.http.routers.elasticsearch.middlewares=elasticsearch-stripprefix"
    ulimits:
      memlock:
        soft: -1
        hard: -1
    mem_limit: "1g"
  #  networks:
   #   - documentrasterizer-network
    healthcheck:
      test: curl -u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD} -s -f localhost:9200/_cat/health >/dev/null || exit 1
      interval: 20s
      timeout: 10s
      retries: 5
    restart: unless-stopped

  kibana:
    image: /example.com/library/kibana:8.9.1
    container_name: ${COMPOSE_PROJECT_NAME}-kibana
    environment:
      - ELASTIC_URL=http://elasticsearch:9200
      - XPACK_SECURITY_ENABLED=false
      - SERVER_BASEPATH=/kibana
      - SERVER_REWRITEBASEPATH=true
   # networks:
   #   - documentrasterizer-network
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.kibana.rule=Host(`${PROJECT_DOMAINS}`) && PathPrefix(`/kibana`)"
      - "traefik.http.routers.kibana.entrypoints=web"
      - "traefik.http.services.kibana.loadbalancer.server.port=5601"
        # - "traefik.http.middlewares.kibana-strip.stripprefix.prefixes=/kibana"
        # - "traefik.http.routers.kibana.middlewares=kibana-strip"
    depends_on:
      - elasticsearch
    restart: unless-stopped

  logstash:
    image:example.com/logstash:8.9.1
    container_name: ${COMPOSE_PROJECT_NAME}-logstash
    ports:
      - "12202:12201/udp"
    environment:
      - "xpack.monitoring.enabled=true"
      - "xpack.monitoring.elasticsearch.hosts=http://${ELASTIC_HOST:-elasticsearch:9200}"
      - "xpack.monitoring.elasticsearch.username=${ELASTIC_USERNAME:-bdtemuser}"
      - "xpack.monitoring.elasticsearch.password=${ELASTIC_PASSWORD:-bdtemuser}"
      - ELASTIC_HOST=${ELASTIC_HOST}
      - ELASTIC_USERNAME=${ELASTIC_USERNAME:-bdtemuser}
      - ELASTIC_PASSWORD=${ELASTIC_PASSWORD:-bdtemuser}
      - ENVIRONMENT=${ENVIRONMENT}
    command: |
      bash -c "while ! curl -u ${ELASTIC_USERNAME}:${ELASTIC_PASSWORD} -s elasticsearch:9200; do sleep 5; done;
      logstash -e '
        input {
          gelf {
            port => 12201
          }
        }
        filter {
          mutate {
            add_tag => [ \"%{tag}\" ]
          }
        }
        output {
          elasticsearch {
            hosts => [\"elasticsearch:9200\"]
            index => \"%{[tag]}-logs-%{+YYYY.MM.dd}\"
            user => \"${ELASTIC_USERNAME}\"
            password => \"${ELASTIC_PASSWORD}\"
            ssl_enabled => false
          }
        }'"
   # networks:
    #  - documentrasterizer-network
    depends_on:
      elasticsearch:
        condition: service_healthy
    restart: unless-stopped
#networks:
 # documentrasterizer-network:
  #  driver: bridge

Not every web application supports a custom external path (using PathPrefix() and potentially stripPrefix ), instead a sub-domain per service is best practice. It’s discussed like here about every other week.

Hello it's a api with .NET it doesn't serve html or js

Your config seems to be a bit messy :wink: A lot of lines commented out, a lot of services not relevant for the issue.

Sometimes you use documentrasteriser with a z.

Then you sometimes use .internal domain.

accesslog.format is totally wrong (doc).

To debug this, I recommend to:

  • enable and check Traefik debug log (doc)
  • enable and check Traefik access log in JSON format (doc)

Maybe start fresh, check simple Traefik example.

hello those line are commented
for the acceslog.format you're right but they can't help me

You could check debug log if the router is recognized correctly with all settings.

You could check access log during request, if the correct router was used (rule matched) and if 404 comes from target container ("OriginStatus") or was only created by Traefik.

You could also enable and check Traefik dashboard (doc).

the log doesn't show something interesting

10.33.150.1 - - [18/Apr/2025:08:41:16 +0000] "GET /kibana/plugins/kibanaReact/assets/solutions_kibana.svg HTTP/1.1" 304 0 "-" "-" 181 "kibana@docker" "http://172.18.0.5:5601" 2ms
2025-04-18T08:41:16Z DBG github.com/traefik/traefik/v3/pkg/server/service/loadbalancer/wrr/wrr.go:196 > Service selected by WRR: 1ff645c0440a967d
10.33.150.1 - - [18/Apr/2025:08:41:16 +0000] "GET /kibana/plugins/kibanaReact/assets/illustration_cloud_migration.png HTTP/1.1" 304 0 "-" "-" 182 "kibana@docker" "http://172.18.0.5:5601" 1ms
2025-04-18T08:41:32Z DBG github.com/traefik/traefik/v3/pkg/server/service/loadbalancer/wrr/wrr.go:196 > Service selected by WRR: 1ff645c0440a967d
10.33.150.1 - - [18/Apr/2025:08:41:32 +0000] "POST /kibana/api/ui_counters/_report HTTP/1.1" 200 15 "-" "-" 183 "kibana@docker" "http://172.18.0.5:5601" 1435ms
10.33.150.1 - - [18/Apr/2025:08:44:02 +0000] "GET /documentrasterizer/api/healthcheck HTTP/1.1" 404 19 "-" "-" 184 "-" "-" 0ms
10.33.150.1 - - [18/Apr/2025:08:47:13 +0000] "GET /documentrasterizer/api/healthcheck HTTP/1.1" 404 19 "-" "-" 185 "-" "-" 0ms

That’s true, because it is not in JSON format, for which I explicitly linked the doc.

same there is no something interesting

2025-04-18T09:07:54Z DBG github.com/traefik/traefik/v3/pkg/server/configurationwatcher.go:127 > Skipping unchanged configuration providerName=docker
{"ClientAddr":"10.33.150.1:26976","ClientHost":"10.33.150.1","ClientPort":"26976","ClientUsername":"-","DownstreamContentSize":19,"DownstreamStatus":404,"Duration":21368,"GzipRatio":0,"OriginContentSize":0,"OriginDuration":0,"OriginStatus":0,"Overhead":21368,"RequestAddr":"exampel.com","RequestContentSize":0,"RequestCount":2,"RequestHost":"example.com","RequestMethod":"GET","RequestPath":"/documentrasterizer/api/healthcheck","RequestPort":"-","RequestProtocol":"HTTP/1.1","RequestScheme":"http","RetryAttempts":0,"StartLocal":"2025-04-18T09:08:44.674807678Z","StartUTC":"2025-04-18T09:08:44.674807678Z","entryPointName":"web","level":"info","msg":"","time":"2025-04-18T09:08:44Z"}
{"ClientAddr":"10.33.150.1:31032","ClientHost":"10.33.150.1","ClientPort":"31032","ClientUsername":"-","DownstreamContentSize":19,"DownstreamStatus":404,"Duration":18837,"GzipRatio":0,"OriginContentSize":0,"OriginDuration":0,"OriginStatus":0,"Overhead":18837,"RequestAddr":"example.com","RequestContentSize":0,"RequestCount":3,"RequestHost":"example.com","RequestMethod":"GET","RequestPath":"/documentrasterizer/api/healthcheck","RequestPort":"-","RequestProtocol":"HTTP/1.1","RequestScheme":"http","RetryAttempts":0,"StartLocal":"2025-04-18T09:15:15.410432773Z","StartUTC":"2025-04-18T09:15:15.410432773Z","entryPointName":"web","level":"info","msg":"","time":"2025-04-18T09:15:15Z"}

@bluepuma77 the problem in health check wa sin healthcheck of my container return always unhealthy status
2025-04-18T09:27:46Z DBG github.com/traefik/traefik/v3/pkg/provider/docker/config.go:199 > Filtering unhealthy or starting container container=api-documentrasteriser-53767f5cdc5839ef58a59548a2b727d59a1ae2a5f29e6db428e518b3a38262de providerName=docker

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