elasticsearch-head连接不上es

修改elasticsearch.yml,增加如下字段

http.cors.enabled: true
http.cors.allow-origin: "*"

cros为: Cross-origin resource sharing ,即跨域访问。

    默认值为false,在elasticsearch安装集群之外的一台机上用head等监控插件访问elasticsearch是不允许的。这个字段最早1.4.x版本,而非5.x开始存在的。

http.cors.用法:

# 是否支持跨域,默认为false
http.cors.enabled

#当设置允许跨域,默认为*,表示支持所有域名,如果我们只是允许某些网站能访问,那么可以使用正则表达式。比如只允许本地地址。 /https?:\/\/localhost(:[0-9]+)?/
http.cors.allow-origin


# 浏览器发送一个“预检”OPTIONS请求,以确定CORS设置。最大年龄定义多久的结果应该缓存。默认为1728000(20天)
http.cors.max-age

# 允许跨域的请求方式,默认OPTIONS,HEAD,GET,POST,PUT,DELETE
http.cors.allow-methods

# 跨域允许设置的头信息,默认为X-Requested-With,Content-Type,Content-Length
http.cors.allow-headers

# 是否返回设置的跨域Access-Control-Allow-Credentials头,如果设置为true,那么会返回给客户端。
http.cors.allow-credentials

image

猜你喜欢

转载自www.cnblogs.com/LC161616/p/9093751.html