<p>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.</p>
<p>Below is my nginx configuration. It works fine for elasticsearch. But when I open <code>/kibana/</code> in browser, it redirects to <code>/spaces/enter</code> and shows <code>404 Not Found</code>.</p>
<p>In kibana container log I can see a 302 forward log:</p>
<p><code>{&quot;type&quot;:&quot;response&quot;,&quot;@timestamp&quot;:&quot;2021-02-24T05:50:32Z&quot;,&quot;tags&quot;:[],&quot;pid&quot;:7,&quot;method&quot;:&quot;get&quot;,&quot;statusCode&quot;:302,&quot;req&quot;:{&quot;url&quot;:&quot;/&quot;,&quot;method&quot;:&quot;get&quot;,&quot;headers&quot;:{&quot;connection&quot;:&quot;Keep-Alive&quot;,&quot;proxy-connection&quot;:&quot;Keep-Alive&quot;,&quot;host&quot;:&quot;kibana-entrypoint:5601&quot;,&quot;x-forwarded-for&quot;:&quot;49.255.115.150&quot;,&quot;x-forwarded-proto&quot;:&quot;http&quot;,&quot;x-forwarded-port&quot;:&quot;80&quot;,&quot;x-amzn-trace-id&quot;:&quot;Root=1-6035e928-603d67da7eff4225005fdbfc&quot;,&quot;upgrade-insecure-requests&quot;:&quot;1&quot;,&quot;user-agent&quot;:&quot;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&quot;,&quot;accept&quot;:&quot;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&quot;,&quot;accept-encoding&quot;:&quot;gzip, deflate&quot;,&quot;accept-language&quot;:&quot;en-GB,en-US;q=0.9,en;q=0.8&quot;},&quot;remoteAddress&quot;:&quot;192.168.1.41&quot;,&quot;userAgent&quot;:&quot;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&quot;},&quot;res&quot;:{&quot;statusCode&quot;:302,&quot;responseTime&quot;:7,&quot;contentLength&quot;:9},&quot;message&quot;:&quot;GET / 302 7ms - 9.0B&quot;}</code></p>
<pre><code>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 &quot;Keep-Alive&quot;;
            proxy_set_header Proxy-Connection &quot;Keep-Alive&quot;;
          }
      }
    }
</code></pre>
<p>The question is why kibana forward the request?</p>

<p><a href="https://github.com/elastic/kibana/pull/66098" rel="nofollow noreferrer"><code>elastic/kibana</code> PR 66098</a> mentions that the <code>/spaces/enter</code> view is used by the space selector UIs to send users to the appropriate default route.</p>
<p>And  <a href="https://github.com/elastic/kibana/pull/44678" rel="nofollow noreferrer">PR 44678</a> explains the origin of the notion of space:</p>
<blockquote>
<p>This deprecates the <code>server.defaultRoute</code> from <code>kibana.yml</code> setting (#46787) in favor of an <strong>Advanced Setting controllable through the UI</strong>.<br />
By making this an advanced setting, it inherently becomes space-aware, so users can specify a custom default route per space.</p>
<h3>Transition</h3>
<p>If <code>server.defaultRoute</code> is specified in <code>kibana.yml</code>, it will be mapped to the <code>uiSettings.overrides.defaultRoute</code> setting.<br />
This setting tells the UI Settings Service that the defaultRoute setting is locked, and cannot be edited via the UI.<br />
From a migration perspective, this is functionally equivalent for users upgrading in a minor release: the setting is only controllable via the <code>yml</code> file.</p>
<h3>Functionality</h3>
<p>Users who wish to take advantage of the space-aware routes simply need to remove the <code>server.defaultRoute</code> setting from their <code>yml</code> file, if set.<br />
If unset, the advanced setting defaults to <code>/app/kibana</code>, which was the previous default value for <code>server.defaultRoute</code>.</p>
</blockquote>
<p>So in your case, check the  <code>kibana.yml</code> used by your Kibana Docker image: try and remove <code>server.defaultRoute</code> if set.</p>
