简体   繁体   中英

I got a 404 when running kibana on docker behind traefik, but elastic can be reached

I am having issues while running ELK on docker, behind Traefik. Every other services are running, but when i try to access to kibana on a browser via its url, I got a 404.

This is my docker-compose.yml:

    version: '3.4'

networks:
  app-network:
    name: app-network
    driver: bridge
    ipam:
      config:
      - subnet: xxx.xxx.xxx.xxx/xxx

services:
  reverse-proxy:
    image: traefik:v2.5
    command:
      --providers.docker.network=app-network
      --providers.docker.exposedByDefault=false
      --entrypoints.web.address=:80
      --entrypoints.websecure.address=:443
      --providers.docker=true
      --api=true
      --api.dashboard=true
    ports:
      - "80:80"
      - "443:443"
    networks:
      app-network:
        ipv4_address: xxx.xxx.xxx.xxx
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /certs/:/certs
    labels:
      - traefik.enable=true
      - traefik.docker.network=public
      - traefik.http.routers.traefik-http.entrypoints=web
      - traefik.http.routers.traefik-http.service=api@internal

  elasticsearch:
     hostname: elasticsearch
     image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
     environment:
       - bootstrap.memory_lock=true
       - cluster.name=docker-cluster
       - cluster.routing.allocation.disk.threshold_enabled=false
       - discovery.type=single-node
       - "ES_JAVA_OPTS=-Xms2048m -Xmx2048m"
     ulimits:
       memlock:
         hard: -1
         soft: -1
     volumes:
       - esdata:/usr/share/elasticsearch/data
     ports:
       - 9200:9200
     networks:
      app-network:
        ipv4_address: xxx.xxx.xxx.xxx
     healthcheck:
       interval: 20s
       retries: 10
       test: curl -s http://localhost:9200/_cluster/health | grep -vq '"status":"red"'
     labels:
      - "traefik.enable=true"
      - "traefik.http.routers.elasticsearch.entrypoints=http"
      - "traefik.http.routers.elastic.rule=Host(`elastic.mydomain.fr`)"
      - "traefik.http.services.elastic.loadbalancer.server.port=9200"

  kibana:
     hostname: kibana
     image: docker.elastic.co/kibana/kibana:7.12.0
     depends_on:
       elasticsearch:
         condition: service_healthy
     environment:
       ELASTICSEARCH_URL: http://elasticsearch:9200
       ELASTICSEARCH_HOSTS: http://elasticsearch:9200
     ports:
       - 5601:5601
     networks:
      app-network:
        ipv4_address: xxx.xxx.xxx.xxx
     links:
      - elasticsearch
     healthcheck:
       interval: 10s
       retries: 20
       test: curl --write-out 'HTTP %{http_code}' --fail --silent --output /dev/null http://localhost:5601/api/status
     labels:
      - "traefik.enable=true"
      - "traefik.http.routers.kibana.entrypoints=http"
      - "traefik.http.routers.kibana.rule=Host(`kibana.mydomain.fr`)"
      - "traefik.http.services.kibana.loadbalancer.server.port=5601"
      - "traefik.http.routers.kibana.entrypoints=websecure"

volumes:
   esdata:
     driver: local

Knowing that, as I said, Elastic and other services can be accessed.

I have already tried to set the basePath, but it did not works either.

Do you have any idea what am I missing?

You named your entrypoints at the top "web" and "websecure", but the labels are using "http" as entrypoint, you have to rename them (except you have defined http as well as entrypoint somewhere else). You have to match the word you are defining in the configuration string: --entrypoints. web .address=:80

So for example: "traefik.http.routers.elasticsearch.entrypoints=web"

Additional Tip: you can remove the label with the loadbalancer port, because as long as you are defining an exposed or mapped port in Docker, Traefik recognises the used port. I have no such line configured for my personal services. - "traefik.http.services.elastic.loadbalancer.server.port=9200"

Thanks for your answer Zeikos, it helps me a lot.

I think it could be closed now

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM