Joey Yi Zhao
Joey Yi Zhao

Reputation: 42434

why does Kibana forward the url to `/spaces/enter`?

I have a kibana running inside docker container in k8s. And I put a nginx as sidecar to forward all traffic to kibana based on path.

Below is my nginx configuration. It works fine for elasticsearch. But when I open /kibana/ in browser, it redirects to /spaces/enter and shows 404 Not Found.

In kibana container log I can see a 302 forward log:

{"type":"response","@timestamp":"2021-02-24T05:50:32Z","tags":[],"pid":7,"method":"get","statusCode":302,"req":{"url":"/","method":"get","headers":{"connection":"Keep-Alive","proxy-connection":"Keep-Alive","host":"kibana-entrypoint:5601","x-forwarded-for":"49.255.115.150","x-forwarded-proto":"http","x-forwarded-port":"80","x-amzn-trace-id":"Root=1-6035e928-603d67da7eff4225005fdbfc","upgrade-insecure-requests":"1","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36","accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9","accept-encoding":"gzip, deflate","accept-language":"en-GB,en-US;q=0.9,en;q=0.8"},"remoteAddress":"192.168.1.41","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"},"res":{"statusCode":302,"responseTime":7,"contentLength":9},"message":"GET / 302 7ms - 9.0B"}

user nginx;
    worker_processes  1;
    events {
      worker_connections  10240;
    }
    http {
      server {
          listen       8080;
          server_name  localhost;
          location /es/ {
            proxy_pass  http://sample-es-entrypoint:9200/;
          }
          location /health {
            proxy_pass  http://sample-es-entrypoint:9200/_cluster/health;
          }
          location /kibana/ {
            proxy_pass  http://kibana-entrypoint:5601/;
            proxy_redirect off;
            proxy_buffering off;
            proxy_http_version 1.1;
            proxy_set_header Connection "Keep-Alive";
            proxy_set_header Proxy-Connection "Keep-Alive";
          }
      }
    }

The question is why kibana forward the request?

Upvotes: 5

Views: 2225

Answers (1)

VonC
VonC

Reputation: 1323483

elastic/kibana PR 66098 mentions that the /spaces/enter view is used by the space selector UIs to send users to the appropriate default route.

And PR 44678 explains the origin of the notion of space:

This deprecates the server.defaultRoute from kibana.yml setting (#46787) in favor of an Advanced Setting controllable through the UI.
By making this an advanced setting, it inherently becomes space-aware, so users can specify a custom default route per space.

Transition

If server.defaultRoute is specified in kibana.yml, it will be mapped to the uiSettings.overrides.defaultRoute setting.
This setting tells the UI Settings Service that the defaultRoute setting is locked, and cannot be edited via the UI.
From a migration perspective, this is functionally equivalent for users upgrading in a minor release: the setting is only controllable via the yml file.

Functionality

Users who wish to take advantage of the space-aware routes simply need to remove the server.defaultRoute setting from their yml file, if set.
If unset, the advanced setting defaults to /app/kibana, which was the previous default value for server.defaultRoute.

So in your case, check the kibana.yml used by your Kibana Docker image: try and remove server.defaultRoute if set.

Upvotes: 2

Related Questions