原文: Elasticsearch 平安篇,通过 Nginx http basic 限度拜访
1. tengine 配置:
#关键点,配置帐号密码
auth_basic "ElasticSearch 登录";# 提示信息
auth_basic_user_file /var/local/password; #密码文件(docker 中 tengine 挂载密码文件)autoindex on;
proxy_pass http://es 服务内网 ip:9200;
2. docker-compose 配置
volumes:
# elasticsearch 通过 nginx http-basic 限度公网拜访
- /data/tengine/conf/password:/var/local/password
留神: 须要手动进入 docker tengine 容器创立 /var/local/password 文件并将明码数据复制进去
3. elasticsearch.yml
cluster.name: "docker-es"
# es 在 docker 外面, 不能用 127.0.0.1
network.host: 0.0.0.0
# 跨域
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, Content-Type, Content-Length, X-User"
4. 重启 elasticsearch & tengine
docker restart elasticsearch
docker-compose up -d tengine