使用 2.4 ES head 插件无法连接到外部 ES 服务器

With 2.4 ES head plugin not able to connect to external ES server

请求的资源上存在 'Access-Control-Allow-Origin' header 的获取错误'

您需要在 elasticsearch.yml 配置中启用 cors:

http.cors.enabled: true

您还需要允许一些来源,因为默认情况下允许 none:

http.cors.allow-origin: "*"

请注意,允许所有来源(即 "*")存在安全风险,因此您也可以对其进行更严格的限制

http.cors.allow-origin: /https?:\/\/localhost(:[0-9]+)?/