提问人:Javerleo 提问时间:11/18/2023 更新时间:11/18/2023 访问量:23
支持 CORS 的 Docker 化 Elasticsearch
Dockerized Elasticsearch with CORS support
问:
我正在尝试设置一个本地 Elasticsearch 实例以用于开发目的。因此,我从一个基本的docker-compose.yml文件开始:
services:
elasticsearch:
image: elasticsearch:8.7.1
ports:
- 9200:9200
environment:
discovery.type: single-node # Runs as a single-node
ES_JAVA_OPTS: '-Xms256m -Xmx256m'
network.bind_host: 0.0.0.0
xpack.security.enabled: 'false'
volumes: # Stores elasticsearch data locally on the esdata Docker volume
- esdata:/usr/share/elasticsearch/data
networks:
- internal
- elastic
# Define the Docker volume named esdata for the Elasticsearch container.
volumes:
esdata:
# Networks to use
networks:
elastic:
external: true
internal:
driver: bridge
这工作正常,以便测试使用 Elasticsearch 的 WordPress 插件。但是,现在我需要避免与CORS相关的错误,因此我尝试向环境中添加参数:
http.cors.enabled: 'true'
http.cors.allow-origin: "*"
http.cors.allow-methods: OPTIONS, HEAD, GET, POST, PUT, DELETE
http.cors.allow-headers: X-Requested-With, X-Auth-Token, Content-Type, Content-Length, Authorization, Access-Control-Allow-Headers, Accept
http.cors.allow-credentials: 'true'
这是行不通的。Elasticsearch 在应用更改后拒绝连接。
因此,我需要的是具有最低限度的安全性,但同时允许来自任何地方的 CORS 请求。
您的建议将不胜感激。
答: 暂无答案
评论