Skip to content

Instantly share code, notes, and snippets.

@w33ble
Last active April 8, 2022 12:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save w33ble/494933b2e5fdab6111c21665b67a9ad2 to your computer and use it in GitHub Desktop.
Save w33ble/494933b2e5fdab6111c21665b67a9ad2 to your computer and use it in GitHub Desktop.
Elastic Stack in Docker with Basic Auth via proxy
version: '2.2'
services:
proxy:
image: nginx:1-alpine
restart: always
ports:
- 5601:80
- 9200:9201
volumes:
- ./nginx/conf.d:/etc/nginx/conf.d
depends_on:
- kibana
- elasticsearch
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:6.4.2
restart: always
volumes:
- ./elasticsearch/data:/usr/share/elasticsearch/data
- ./elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
environment:
- discovery.type=single-node
- bootstrap.memory_lock=true
ulimits:
memlock:
soft: -1
hard: -1
kibana:
image: localhost:5000/kibana:6.4.2 # custom kibana build, docker.elastic.co/kibana/kibana:6.4.2 would also work
restart: always
environment:
- ELASTICSEARCH_USERNAME=elastic
- ELASTICSEARCH_PASSWORD=changeme
- ELATSICSEARCH_URL=http://proxy:9201
cluster.name: "docker-cluster"
network.host: 0.0.0.0
discovery.zen.minimum_master_nodes: 1
server {
listen 9201;
server_name elasticsearch;
# permit large uploads
client_max_body_size 25M;
location / {
auth_basic "Don't touch me there";
auth_basic_user_file /etc/nginx/conf.d/htpasswd;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_pass http://elasticsearch:9200;
}
}
server {
listen 80;
server_name kibana;
# permit large uploads
client_max_body_size 25M;
location / {
auth_basic "Don't touch me there";
auth_basic_user_file /etc/nginx/conf.d/htpasswd;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_buffering off;
proxy_pass http://kibana:5601;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment