kibana server.basePath results in 404

∥☆過路亽.° 提交于 2020-01-13 10:38:07

问题


I am running kibana 4.4.1 on RHEL 7.2

Everything works when the kibana.yml file does not contain the setting server.basePath. Kibana successfully starts and spits out the message

[info][listening] Server running at http://x.x.x.x:5601/

curl http://x.x.x.x:5601/app/kibana returns the expected HTML.

However, when basePath is set to server.basePath: "/kibana4", http://x.x.x.x:5601/kibana4/app/kibana results in a 404. Why?

The server successfully starts with the same logging

[info][listening] Server running at http://x.x.x.x:5601/

but

curl http://x.x.x.x:5601/ returns

<script>
  var hashRoute = '/kibana4/app/kibana';
  var defaultRoute = '/kibana4/app/kibana';
  ...
</script>

curl http://x.x.x.x:5601/kibana4/app/kibana returns {"statusCode":404,"error":"Not Found"}

Why does '/kibana4/app/kibana' return a 404?


回答1:


server.basePath does not behave as I expected.

I was expecting server.basePath to symmetrically affect the URL. Meaning that request URLs would be under the subdomain /kibana4 and response URLs would also be under the subdomain /kibana4.

This is not the case. server.basePath asymetrically affects the URL. Meaning that all request URLs remain the same but response URLs have included the subdomin. For example, the kibana home page is still accessed at http://x.x.x.x:5601/app/kibana but all hrefs URLs include the subdomain /kibana4.

server.basePath only works if you use a proxy that removes the subdomain before forwarding requests to kibana

Below is the HAProxy configuration that I used

frontend main *:80
   acl url_kibana   path_beg   -i /kibana4
   use_backend kibana   if url_kibana

backend kibana
   mode http
   reqrep ^([^\ ]*)\ /kibana4[/]?(.*) \1\ /\2\
   server x.x.x.x:5601

The important bit is the reqrep expression that removes the subdomain /kibana4 from the URL before forwarding the request to kibana.



来源:https://stackoverflow.com/questions/36266776/kibana-server-basepath-results-in-404

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!