|
1 | | -# Elastic - Kibana - Docker - Nginx - Letsencrypt |
| 1 | +# Setting up secure Elastic DB and Kibana with Docker |
| 2 | + |
| 3 | +This guide will walk you through the steps to set up Elastic DB and Kibana using Docker Desktop. This is a basic setup with no security or password configuration. |
| 4 | +`If for simple setup, you can check [elasticdb](./../elasticdb/readme.md) |
2 | 5 |
|
3 | 6 | --- |
4 | 7 |
|
5 | | -### Introduction |
| 8 | +## Prerequisites |
| 9 | + |
| 10 | +Before you begin, ensure you have Docker Desktop installed on your system. If not, follow the steps below to install Docker Desktop: |
| 11 | + |
| 12 | +1. **Install Docker Desktop:** |
| 13 | + - Go to the Docker website: [https://www.docker.com/products/docker-desktop](https://www.docker.com/products/docker-desktop) |
| 14 | + - Download Docker Desktop for your operating system (Windows/Mac). |
| 15 | + - Follow the installation instructions provided for your platform. |
6 | 16 |
|
7 | | -Setup a Elastic + Kibana stack in seconds! Ready for public use with TLS enabled between nodes, and automatic SSL/TLS certificates + renewal with certbot and Nginx. |
| 17 | +## Setup Elastic DB and Kibana |
8 | 18 |
|
9 | | -Docker-compose follows Elastic's official documentation for creating a Elastic Stack on Docker. More information can be found on their official site. |
10 | | -https://www.elastic.co/guide/en/elastic-stack-get-started/current/get-started-docker.html |
11 | | -https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-tls-docker.html |
| 19 | +Follow these steps to set up Elastic DB and Kibana using Docker Desktop: |
12 | 20 |
|
13 | | -### DISCLAIMER |
| 21 | +1. **Create .env file, and put env variables like in example.env file:** |
14 | 22 |
|
15 | | -Instructions and scripts are designed to be used with the version listed in the .env file. |
| 23 | + ```env |
| 24 | + ELASTIC_VERSION=8.8.0 |
| 25 | + KIBANA_VERSION=8.7.1 |
| 26 | + ELASTIC_SECURITY=true |
| 27 | + ELASTIC_PASSWORD=password |
| 28 | + KIBANA_PASSWORD=passwordkibana |
| 29 | + COMPOSE_PROJECT_NAME=es |
| 30 | + CERTS_DIR=/usr/share/elasticsearch/config/certificates |
| 31 | + KIBANA_ENCRYPTION_KEY=random32CharactorString |
| 32 | + ELASTIC_PORT=9200 |
| 33 | + KIBANA_PORT=5601 |
16 | 34 |
|
17 | | -### Instructions |
| 35 | + ``` |
18 | 36 |
|
19 | | -1. Create Certificate Authority: |
| 37 | +2. **Create Certificate Authority:** |
20 | 38 | - Install Openssl if your system don't have. |
21 | 39 | - Certificate Url [Opensssl Download](https://knowledge.digicert.com/solution/generate-a-certificate-signing-request-using-openssl-on-microsoft-windows-system) |
22 | | - - private key |
23 | | - `openssl genpkey -algorithm RSA -out ca.key` |
| 40 | + - create folder: |
| 41 | + |
| 42 | + ```bash |
| 43 | + mkdir -p folder/subfolder |
| 44 | + ``` |
| 45 | + |
| 46 | + - create private key |
| 47 | + |
| 48 | + ```bash |
| 49 | + openssl genpkey -algorithm RSA -out certs/ca/ca.key |
| 50 | + ``` |
| 51 | + |
24 | 52 | - private certificate |
25 | | - `openssl req -x509 -new -key ca.key -out ca.crt`. |
26 | 53 |
|
27 | | -2. Setup Docker Compose: (https://github.com/wdrdres3qew5ts21/MeetU/blob/master/docker-compose-elastic-single-full-ssl.yml) |
28 | | - |
29 | | -3. |
| 54 | + ```bash |
| 55 | + openssl req -x509 -new -key certs/ca/ca.key -out certs/ca/ca.crt |
| 56 | + ``` |
| 57 | + |
| 58 | + - after this you will see certs folder with ca certificates. |
| 59 | + |
| 60 | +3. **Create TLS certificates for encrypted communications between nodes:** |
| 61 | + |
| 62 | + ```bash |
| 63 | + docker-compose -f create-certs.yml run --rm create_certs |
| 64 | + ``` |
| 65 | + |
| 66 | + - in cert folder you will see es01 and kib01 folder respectively. |
| 67 | + |
| 68 | +4. **Run Docker Compose:** |
| 69 | + |
| 70 | + ```bash |
| 71 | + docker-compose up -d |
| 72 | + ``` |
| 73 | + |
| 74 | + This command will start Elastic DB and Kibana containers in the background. |
| 75 | + |
| 76 | +5. **Change Password for kibana** |
| 77 | + |
| 78 | + - open bash inside es01 container |
| 79 | + |
| 80 | + ```bash |
| 81 | + docker exec -it es01 bash |
| 82 | + ``` |
| 83 | + |
| 84 | + - run changePassword.sh mounted inside the container |
| 85 | + |
| 86 | + ```bash |
| 87 | + sh /usr/share/elasticsearch/changePassword.sh |
| 88 | + ``` |
| 89 | + |
| 90 | +6. **Access Elastic Kibana:** |
| 91 | + - Open your web browser and go to [https://localhost:5601](https://localhost:5601). |
| 92 | + - You should see the Kibana login page. |
| 93 | + - put user as: elastic and password value from your env file ELASTIC_PASSWORD. |
| 94 | + |
| 95 | + |
| 96 | +## Notes |
| 97 | + |
| 98 | +- By default, this setup does not include any security or password protection. It's recommended to configure security settings according to your requirements before deploying to production. |
| 99 | +- Ensure that Docker Desktop is running before executing Docker Compose commands. |
| 100 | +- Docker-compose follows Elastic's official documentation for creating a Elastic Stack on Docker. More information can be found on their official site. |
| 101 | +<https://www.elastic.co/guide/en/elastic-stack-get-started/current/get-started-docker.html> |
| 102 | +<https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-tls-docker.html> |
| 103 | + |
0 commit comments