CentOS 7安裝elasticsearch-head插件及外放訪問配置

1.在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

2.查看版本信息,證明安裝成功

grunt -version

3.修改配置文件:vi elasticsearch-head/_site/app.js

this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";

修改localhost爲你的IP 例如:192.168.x.x

4.修改配置文件,末尾添加以下配置 config/elasticsearch.yml

http.cors.enabled: true

http.cors.allow-origin: "*"

http.cors.allow-credentials: true 

5.修改elasticsearch-head下Gruntfile.js

connect: {

        server: {

            options: {

                hostname: '0.0.0.0',

                port: 9100,

                base: '.',

                keepalive: true

            }

        }

    }
提醒:4、5同時也解決head連不上es,集羣健康值: 未連接

6.啓動head

cd elasticsearch-head

grunt server 或者 npm run start啓動,後臺啓動:nohup grunt server &

# 打開瀏覽器 http://IP:9100

7.elasticsearch安裝x-pack插件之後,head插件就無法使用了,因爲x-pack中加入了安全模塊(security機制),這個時候需要在elasticseach.yml中再增加下面一行配置即可解決

http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章