如果以stand-alone模式来使用elasticsearch-head的话(用一个独立于ES的Web服务伺服elasticsearch-head),并且使用SearchGuard为ES开启Https以及Http Basic Auth的话,参见如下说明:
1、首先,确认Elasticsearch可以接受跨域的Ajax请求,在其配置文件中添加如下选项:
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
2、访问elasticsearch-head时,在URL上加上 auth_user
和 auth_password
参数,比如以下:
http:// localhost:9100/_plugin/head/?auth_user=admin&auth_password=admin
以上两个参数值,就是SearchGuard为ES添加的Http basic认证的用户名和密码。
3、在elasticsearch-head中,的elasticsearch连接地址处,填入https地址,比如以下:
https://127.0.0.1:9200/
注意是https协议头,之后就可以正常连接了。