原文: 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
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。