About several paths on my localhost. Error 404

there are web app and efk(elasticsearch + fluentd + kibana) stack in my docker-compose file. I want app working on localhost/api path and kibana on localhost on localhost/kibana path. The problem is app is working, kibana - not. I get 404 error. But if I run kibana on localhost without path it works fine.
web_app's code:

web_app:
    build: .
    volumes:
      - .:/usr/src/app/volumes/web/
    env_file:
      - ./.env.dev
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.web_app.rule=(Host(`localhost`) && Path(`/api`))"
      - "traefik.http.middlewares.web_app-stripprefix.stripprefix.prefixes=/api,/api/"
      - "traefik.http.routers.web_app.middlewares=web_app-stripprefix@docker"
      - "traefik.http.services.web_app.loadbalancer.server.port=8081"
    depends_on:
      - reverse-proxy
      - db
    networks:
      - traefik-public

and kibana's code here:

  kibana:
    image: kibana:7.2.0
    links:
      - "elasticsearch"
    expose:
      - "5601"
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.kibana.rule=(Host(`localhost`) && Path(`/kibana`))"
      - "traefik.http.middlewares.kibana-stripprefix.stripprefix.prefixes=/kibana,/kibana/"
      - "traefik.http.routers.kibana.middlewares=kibana-stripprefix@docker"
      - "traefik.http.services.kibana.loadbalancer.server.port=5601"
    networks:
      - traefik-public

and external network:

networks:
  traefik-public:
    external:
      name: traefik-public

Hi @PinkFairy,

Welcome to the community.

You almost certainly want to use PathPrefix. Path matched strictly the path(s) listed.

But it does not change anything... The same 404 error. And traefik redirects me from localhost/kibana to localhost/app/kibana. Do not know what does it mean

But you don't have a rule for localhost/kibana, your rule is for tradeplatform.local/kibaba

yeach, sorry, i've changed host to localhost, added pathprefix - that's right reply. And everything is the same

My suggest is to enable the Traefik accesslog. The access log contains what router(if any) handles the request.

I'm going to guess that kibana is not configured to prefix the paths returned in it's responses.
A quick look suggests to me that setting kibana's server.basePath should do that, and you can remove the stipprefix middleware.

Yeah, you are absolutely right, thank you so much!

1 Like

You're welcome, glad I could help.

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