Giter Club home page Giter Club logo

elastic-kibana-docker-nginx-letsencrypt's Introduction

Elastic - Kibana - Docker - Nginx - Letsencrypt


Introduction

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.

Docker-compose follows Elastic's official documentation for creating a Elastic Stack on Docker. More information can be found on their official site. https://www.elastic.co/guide/en/elastic-stack-get-started/current/get-started-docker.html https://www.elastic.co/guide/en/elasticsearch/reference/current/configuring-tls-docker.html

DISCLAIMER

Instructions and scripts are designed to be used with the version listed in the .env file.

Instructions

  1. Create TLS certificates for encrypted communications between nodes docker-compose -f create-certs.yml run --rm create_certs

  2. Edit nginx/config.conf and init-letsencrypt.sh and replace DOMAINNAME.com with your actual domain.

  3. Execute the init-letsencrypt.sh script to generate LetsEncrypt certificates for nginx.

    chmod +x init-letsencrypt.sh
    sudo ./init-letsencrypt.sh
    
  4. (Optional) In case there is an error starting the stack: a. Run :

    sysctl -w vm.max_map_count=262144
    

    b. To make the changes permanent insert the new entry into the /etc/sysctl.conf file with the required parameter:

    vm.max_map_count = 262144
    
    

    c. To take effect restart docker :

    sudo systemctl restart docker
    
  5. Run the elasticsearch-generate-passwords tool on es01 to generate passwords for all built-in users and kibana_system. Make note of these passwords.

    docker exec es01 /bin/bash -c "cp /usr/share/elasticsearch/config/certificates/ca/ca.crt /usr/local/share/ca-certificates"
    docker exec es01 /bin/bash -c "update-ca-certificates"
    docker exec es01 /bin/bash -c "bin/elasticsearch-setup-passwords auto --batch --url https://es01:9200"
    
  6. Edit .env file : Replace ELASTIC_PASSWORD with the randomly generated password for kibana_system. You'll also want to replace KIBANA_ENCRYPTION_KEY with a randomly generated (use your own), 32 character alphanumeric value. This is used for encrypting API keys for Elastic Agent fleets.

  7. Restart your stack, and you should have a fully working elastic stack with HTTPS enabled!

    docker-compose stop
    docker-compose up -d
    
  8. To login to Kibana the username is elastic and your password is the value of elastic (the one generated in step 6)

elastic-kibana-docker-nginx-letsencrypt's People

Contributors

datallboy avatar juan-vg avatar stgeipel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

elastic-kibana-docker-nginx-letsencrypt's Issues

Add Created CA to the Trust Set

In order to generate the random passwords the elasticsearch-setup-passwords binary requires to trust the ES certs. Step 6 must be modified to handle first the CA addition to the trust set.

6. Run the *elasticsearch-generate-passwords* tool on es01 to generate passwords for all built-in users and kibana_system. Make note of these passwords.
    ```
    docker exec es01 /bin/bash -c "ln -s /usr/share/elasticsearch/config/certificates/ca/ca.crt /etc/pki/ca-trust/source/anchors/es-cluster-ca.crt"
    docker exec es01 /bin/bash -c "update-ca-trust"
    docker exec es01 /bin/bash -c "bin/elasticsearch-setup-passwords auto --batch --url https://es01:9200"
    ```

Originally posted by @juan-vg in #1 (comment)

failed to resolve host [es02]

Thank you very much for this repo. Finally all together🙂

I have a fresh machine in the cloud where I run this repo.

The open ports are 80, 443, 8080, 9200, 5601.
System: Ubuntu 20.04
Docker: 20.10.12, build e91ed57
docker-compose: 1.29.2, build 5becea4c

When running your instructions, I see the following error message using "docker logs -f es01":

{"type": "server", "timestamp": "2022-01-17T11:58:16,798Z", "level": "WARN", "component": "o.e.d.SeedHostsResolver", "cluster.name": "es-docker-cluster", "node.name": "es01", "message": "failed to resolve host [es02]", "stacktrace": ["java.net.UnknownHostException: es02", "at java.net.InetAddress$CachedAddresses.get(InetAddress.java:801) ~[?:?]", "at java.net.InetAddress.getAllByName0(InetAddress.java:1509) ~[?:?]", "at java.net.InetAddress.getAllByName(InetAddress.java:1367) ~[?:?]", "at java.net.InetAddress.getAllByName(InetAddress.java:1301) ~[?:?]", "at org.elasticsearch.transport.TcpTransport.parse(TcpTransport.java:597) ~[elasticsearch-7.16.2.jar:7.16.2]", "at org.elasticsearch.transport.TcpTransport.addressesFromString(TcpTransport.java:539) ~[elasticsearch-7.16.2.jar:7.16.2]", "at org.elasticsearch.transport.TransportService.addressesFromString(TransportService.java:1111) ~[elasticsearch-7.16.2.jar:7.16.2]", "at org.elasticsearch.discovery.SeedHostsResolver.lambda$resolveHostsLists$0(SeedHostsResolver.java:152) ~[elasticsearch-7.16.2.jar:7.16.2]", "at java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[?:?]", "at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingRunnable.run(ThreadContext.java:718) ~[elasticsearch-7.16.2.jar:7.16.2]", "at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) [?:?]", "at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) [?:?]", "at java.lang.Thread.run(Thread.java:833) [?:?]"] }

When I continue, I get the following message when executing the line
docker exec es01 /bin/bash -c "bin/elasticsearch-setup-passwords auto --batch --url https://es01:9200"

`Failed to determine the health of the cluster running at https://es01:9200
Unexpected response code [503] from calling GET https://es01:9200/_cluster/health?pretty
Cause: master_not_discovered_exception

It is recommended that you resolve the issues with your cluster before running elasticsearch-setup-passwords.
It is very likely that the password changes will fail when run against an unhealthy cluster.

Unexpected response code [503] from calling PUT https://es01:9200/_security/user/apm_system/_password?pretty
Cause: Cluster state has not been recovered yet, cannot write to the [null] index

Possible next steps:

  • Try running this tool again.
  • Try running with the --verbose parameter for additional messages.
  • Check the elasticsearch logs for additional error details.
  • Use the change password API manually.

ERROR: Failed to set password for user [apm_system].`

Can someone please tell me what I am doing wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.