1、在ES的配置文件elasticsearch.yml添加
http.cors.enabled: true
http.cors.allow-origin: "*"
http.cors.allow-headers: Authorization
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
2、生成賬號密碼
/bin/elasticsearch-setup-passwords? auto? //自動生成密碼,kibana、logstash、filebeat的密碼自動生成
/bin/elasticsearch-setup-passwords? interactive? //交互式生成密碼,每個密碼自定義
3、在kibana配置文件中添加用戶名和密碼
在kibana.yml文件最后添加
elasticsearch.username: "elastic"? ? //默認賬號,不能修改
elasticsearch.password: "hello12345"? //自定義密碼
4、在logstash輸出中配置用戶名和密碼
output {
? elasticsearch {
? ? hosts => ["127.0.0.1:9200"]
? ? ? ? index => "logstash-nginx"
? ? ? ? workers => 1
? ? ? ? template_overwrite => true
? ? ? ? user => "elastic"
? ? ? ? password => "Oracle1234!"
? }
stdout { codec => rubydebug }
}
https://www.yangxinghui.com/599.html
密碼驗證:
本地 驗證 elastic 賬戶
curl -u elastic 'http://localhost:9200/_xpack/security/_authenticate?pretty'
重置 elastic 賬戶密碼
curl -u elastic -XPUT 'http://localhost:9200/_xpack/security/user/elastic/_password?pretty' -H 'Content-Type: application/json' -d'{"password" : "elastic"}
參考: