ElasticSearch(八)Elasticsearch-head 连接不上Elasticsearch的原因和解决方案

在上篇博文里ElasticSearch(七) Elasticsearch在Centos下搭建可视化服务中已经访问到了可视化界面。然后兴奋地进行了数据提交测试,提交啊,刷新啊,就是看不到数据变化,仔细一看,原来还没连接呢

//编辑配置文件
# vim /etc/elasticsearch/elasticsearch.yml

//增加下面两项
http.cors.enabled: true
http.cors.allow-origin: "*"
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,那么会返回给客户端。
 

猜你喜欢

转载自www.cnblogs.com/wt645631686/p/10056023.html