# 去github上下载head git clone git://github.com/mobz/elasticsearch-head.git # 因为head基于nodejs因此安装它 yum -y install nodejs npm npm install grunt-cli npm install grunt grunt -version # 修改配置文件 cd elasticsearch-head vim _site/app.js # 修改 『http://localhost:9200』字段到本机ES端口与IP
cd elasticsearch-head grunt server # 打开浏览器 http://localhost:9100
“集群健康值: 未链接”
vim $ES_HOME$/config/elasticsearch.yml # 增长以下字段 http.cors.enabled: true http.cors.allow-origin: "*"
重启es和head便可node
wiki上的解释是 Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources ,即跨域访问。git
这个字段默认为false,在Elasticsearch安装集群以外的一台机上用Sense、Head等监控插件访问Elasticsearch是不容许的。这个字段最先能够追溯到1.4.x版本,而非5.x特有。github
具体这个http.cors.x字段还有哪些用途和用法,见下表:正则表达式
http.cors.enabled | 是否支持跨域,默认为false |
http.cors.allow-origin | 当设置容许跨域,默认为*,表示支持全部域名,若是咱们只是容许某些网站能访问,那么可使用正则表达式。好比只容许本地地址。 /https?:\/\/localhost(:[0-9]+)?/ |
http.cors.max-age | 浏览器发送一个“预检”OPTIONS请求,以肯定CORS设置。最大年龄定义多久的结果应该缓存。默认为1728000(20天) |
http.cors.allow-methods | 容许跨域的请求方式,默认OPTIONS,HEAD,GET,POST,PUT,DELETE |
http.cors.allow-headers | 跨域容许设置的头信息,默认为X-Requested-With,Content-Type,Content-Length |
http.cors.allow-credentials | 是否返回设置的跨域Access-Control-Allow-Credentials头,若是设置为true,那么会返回给客户端。 |