关于.htaccess:Kibana的Apache反向代理

Apache reverse proxy for Kibana

我目前正在尝试设置一个Apache服务器,以将例如localhost / kibana重定向到位于localhost:5601的Kibana。

我尝试将其添加到apache2.conf:

1
2
ProxyPass /kibana http://localhost:5601
ProxyPassReverse /kibana http://localhost:5601

但是,它卡在了Kibana的"正在加载组件"页面上,实际上从未完全加载。更改为以下内容时将起作用:

1
2
ProxyPass /kibana/ http://localhost:5601/
ProxyPassReverse /kibana/ http://localhost:5601/

很明显,强迫用户最后输入多余的/是不理想的,因此我尝试用.htaccess中的URL进行重写:

1
2
RewriteEngine On
RewriteRule http://localhost/kibana$ http://localhost/kibana/

但是重写似乎不起作用。我已经将AllowOverride设置为all并启用了重写模块,并使用了各种不同的重写/代理规则,但到目前为止还没有任何运气。


我已经用elasticsearch完成了针对kibana的apache配置文件。它可能对您有用:

/etc/httpd/conf.d/kibana.conf:

1
2
3
4
5
6
7
8
9
10
11
12
13
ProxyRequests On

ProxyPass /app/kibana http://127.0.0.1:5601/app/kibana
ProxyPassReverse /app/kibana http://127.0.0.1:5601/app/kibana

ProxyPass /elasticsearch http://127.0.0.1:9200/
ProxyPassReverse /elasticsearch http://127.0.0.1:9200/

Alias /bundles/ /opt/kibana/optimize/bundles/

<Directory /opt/kibana>
    Require all granted
</Directory>

这样,它不需要任何其他的" /",并且可以与默认的kibana配置文件一起使用。