大家好,我正在尝试使用Docker建立ELK stack +Nginx(用于负载均衡和基本身份验证)。我的问题是:我不能使用Nginx作为负载均衡器,当我试图访问kibana web ui时,从来没有问过我任何密码。如何重新安排我的docker compose以实现安全性和负载平衡?我使用的是windows 10。
我的文件结构如下:

我的docker-compose.yml:
version: '2'
services:
elasticsearch:
container_name: esc
image: esi:1.0.0
build: ./es
volumes:
- ./data/es:/usr/share/elasticsearch/data
ports:
- 9200:9200
expose:
- 9300
kibana:
container_name: kibanac
image: kibanai:1.0.0
build: ./kibana
links:
- elasticsearch
ports:
- 5601:5601
nginx:
image: nginx:latest
restart: unless-stopped
volumes:
- ./nginx/config:/etc/nginx/conf.d:ro,Z
- ./nginx/htpasswd.users:/etc/nginx/htpasswd.users:ro,Z
ports:
- "8890:8890"
depends_on:
- elasticsearch
- kibanaDocker守护进程:

Nginx.conf:
upstream elasticsearch {
server localhost:9200;
keepalive 15;
}
upstream kibana {
server localhost:5601;
keepalive 15;
}
server {
listen 8888;
location / {
auth_basic "Protected Elasticsearch";
auth_basic_user_file /etc/nginx/htpasswd.users;
proxy_pass http://localhost:9200;
proxy_redirect off;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}
server {
listen 8889;
location / {
auth_basic "Protected Kibana";
auth_basic_user_file /etc/nginx/htpasswd.users;
proxy_pass http://localhost:5601;
proxy_redirect off;
proxy_buffering off;
proxy_http_version 1.1;
proxy_set_header Connection "Keep-Alive";
proxy_set_header Proxy-Connection "Keep-Alive";
}
}
Kibana.yml: ( calling for kibana ui-> localhost:5601)
server.name: kibana
server.host: "0"
elasticsearch.url: http://elasticsearch:9200
elasticsearch.username: elastic
elasticsearch.password: changeme
xpack.monitoring.ui.container.elasticsearch.enabled: true
Elasticsearch.yml: ( calling for elasticsearch-> localhost:9200)
http.host: 0.0.0.0
### x-pack functions
xpack.security.enabled: false
xpack.monitoring.enabled: true
xpack.graph.enabled: false
xpack.watcher.enabled: false
Dockerfile for Kibana:
FROM docker.elastic.co/kibana/kibana:6.6.2
COPY ./config/kibana.yml /opt/kibana/config/kibana.yml
Dockerfile for Elasticsearch:
FROM docker.elastic.co/elasticsearch/elasticsearch:6.6.2
COPY ./config/elasticsearch.yml
/usr/share/elasticsearch/config/elasticsearch.yml发布于 2019-03-22 17:10:12
请在您访问Kibana web UI的nginx配置中添加ip地址或域名。
listen ip_address_or_domain_name:8889; 和:
proxy_pass http://kibana;在docker-compose.yml文件中:
ports:
- "8890:8889"请注意,其端口为8889。
https://stackoverflow.com/questions/55295976
复制相似问题