Kibana with nginx as a reverse-proxy just results in a 404 error
It seems that the kibana server.rewriteBasePath
option does not work as expected. I fixed this by updating the nginx config to do an explicit rewrite, and setting rewriteBasePath
to false
.
New nginx.conf:
location /kibana { proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Connection "Keep-Alive"; proxy_set_header Proxy-Connection "Keep-Alive"; proxy_pass http://kibana:5601/; proxy_read_timeout 90; proxy_redirect http://kibana:5106 https://my.host.com/kibana; rewrite /kibana/(.*)$ /$1 break; proxy_buffering off; }
New kibana.yml:
elasticsearch.hosts: ["http://elasticsearch:9200"]logging.dest: stdoutserver.host: kibanaserver.basePath: /kibanaserver.rewriteBasePath: false
(I've reported this as a bug in the kibana issue tracker.)
Without a kibana.yml
, just using environment
in a docker-compose.yml
:
kib01: image: docker.elastic.co/kibana/kibana:7.10.2 ports: - 5601:5601 environment: - ELASTICSEARCH_URL=http://es01:9200 - ELASTICSEARCH_HOSTS=http://es01:9200 - ELASTICSEARCH_USERNAME=elastic - "ELASTICSEARCH_PASSWORD={{ elastic_password }}" - SERVER_BASEPATH=/kibana
In the nginx:
location /kibana { rewrite ^/kibana(.*)$ $1 break; proxy_pass http://kib01:5601; }