# ========== # Install Java # ========== # Note: # Since elasticsearch version 7, java is included in the elastic search package, # but version 6 DOES NOT contain java. # Elasticsearch requires at least Java 8 in order to run. It supports both OpenJDK # and Oracle Java. In this guide, we will install OpenJDK version 8. # # We install default-jdk, whi installs (on debian 10) OpenJDK version 11 # apt-get install default-jdk # ========== # Install ElasticSearch # ========== # --- # NOTE: # we will install a package of ElasticSearch which contains only features # that are available under the Apache 2.0 license (elasticsearch-oss) # --- # Install 'apt-transport-https' package # apt-get install apt-transport-https # Import the Elasticsearch PGP Key # wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - # Save the repository definition to '/etc/apt/sources.list.d/elastic-7.x.list' # echo "deb https://artifacts.elastic.co/packages/oss-6.x/apt stable main" \ | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list echo "deb https://artifacts.elastic.co/packages/oss-7.x/apt stable main" \ | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list # Install the Elasticsearch Debian package with: apt-get update apt-get install elasticsearch-oss # ========== # Configure ElasticSearch # ========== ELASTIC_SEARCH_PUBLISH_IP="0.0.0.0" ELASTIC_SEARCH_PORT=9200 # --- # Set System properties # --- # Set set sysctl value 'vm.max_map_count' to '524288' # # Add to /etc/sysctl.conf: # # vm.max_map_count = 524288 # # Note: # if installing ElasticSearch into a LX_Container, do this at # the host system # cat << EOF >> /etc/sysctl.conf # Needed by ElasticSearch Installation on virtual guest # systems (LX-Containers) # # The error message there was: # max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] # vm.max_map_count = 524288 EOF # --- # Adjust file '/etc/elasticsearch/elasticsearch.yml' # --- # Set network.host to '$ELASTIC_SEARCH_PUBLIC_IP' # if ! grep -q -E "^\s*network.host:\s+${ELASTIC_SEARCH_PUBLISH_IP}" /etc/elasticsearch/elasticsearch.yml ; then if grep -q -E "^\s*#network.host:" /etc/elasticsearch/elasticsearch.yml ; then perl -i.ORIG -n -p -e "s/^(#network.host:.*)/\1\nnetwork.host: ${ELASTIC_SEARCH_PUBLISH_IP}/" \ /etc/elasticsearch/elasticsearch.yml else cat << EOF >> /etc/elasticsearch/elasticsearch.yml # Additional User Setting (network.host:) # network.host: $ELASTIC_SEARCH_PUBLISH_IP EOF fi fi # Set http.port to '$ELASTIC_SEARCH_PORT' # if ! grep -q -E "^\s*http.port:\s+${ELASTIC_SEARCH_PORT}" /etc/elasticsearch/elasticsearch.yml ; then if grep -q -E "^\s*#http.port:" /etc/elasticsearch/elasticsearch.yml ; then perl -i.ORIG -n -p -e "s/^(#http.port:.*)/\1\nhttp.port: ${ELASTIC_SEARCH_PORT}/" \ /etc/elasticsearch/elasticsearch.yml else cat << EOF >> /etc/elasticsearch/elasticsearch.yml # Additional User Setting (http.port:) # http.port: $ELASTIC_SEARCH_PORT EOF fi fi # Activate sysctl settings at file '/etc/sysctl.conf' # sysctl -p # --- # Note: # If running as systemd managed process in a LX-Container, the following # systemd parameters will be set: # LimitNOFILE=65535 # LimitNPROC=4096 # LimitAS=infinity # LimitFSIZE=infinity # # Take care, your container satisfies this values. # --- # ========== # Test Elasticsearch Setup # ========== # The Elasticsearch service is ready to use. You can test it using curl command line # utility. Run the simple GET command using curl to verify the setup. You will see # the Elasticsearch cluster details with the version on your screen. # # example output: # # verdi-es:~ # curl -X GET http://${ELASTIC_SEARCH_PUBLISH_IP}:9200 # { # "name" : "verdi-es", # "cluster_name" : "elasticsearch", # "cluster_uuid" : "J54WIwEqQe203nUbtgOOEA", # "version" : { # "number" : "7.2.0", # "build_flavor" : "oss", # "build_type" : "deb", # "build_hash" : "508c38a", # "build_date" : "2019-06-20T15:54:18.811730Z", # "build_snapshot" : false, # "lucene_version" : "8.0.0", # "minimum_wire_compatibility_version" : "6.8.0", # "minimum_index_compatibility_version" : "6.0.0-beta1" # }, # "tagline" : "You Know, for Search" # } # verdi-es:~ # # curl -X GET http://${ELASTIC_SEARCH_PUBLISH_IP}:9200 # ========== # Install Kibana (kibana-oss) # ========== # Same as Elasticsearch, we will install the latest version of Kibana using the # apt package manager from the official Elastic repository: # apt-get install kibana-oss # Specifies the address to which the Kibana server will bind. IP addresses and host # names are both valid values. The default is 'localhost', which usually means # remote machines will not be able to connect. # To allow connections from remote users, set this parameter to a non-loopback address. # # Set server.host to 'localhost' # if ! grep -q -E "^\s*server.host:\s+localhost" /etc/kibana/kibana.yml ; then if grep -q -E "^\s*#server.host:" /etc/kibana/kibana.yml ; then perl -i.ORIG -n -p -e "s/^(#server.host:.*)/\1\nserver.host: localhost/" \ /etc/kibana/kibana.yml else cat << EOF >> /etc/kibana/kibana.yml # Additional User Setting (server.host:) # server.host: localhost EOF fi fi # Start the Kibana service and set it to start automatically on boot: # systemctl restart kibana systemctl enable kibana # ========== # Configure nginx webserver # ========== WEBSITE=verdi-elk.warenform.de cat < /etc/nginx/sites-available/${WEBSITE}.conf server { listen 80; listen [::]:80 ; server_name ${WEBSITE}; return 301 https://\$host\$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name ${WEBSITE}; root /var/www/html; index index.html index.htm index.nginx-debian.html; # Include location directive for Let's Encrypt ACME Challenge # # Needed for (automated) updating certificate # include snippets/letsencrypt-acme-challenge.conf; # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits # # To generate a dhparam.pem file, run in a terminal # openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 # ssl_dhparam /etc/nginx/ssl/dhparam.pem; # Eable session resumption to improve https performance ssl_session_cache shared:SSL:50m; ssl_session_timeout 10m; ssl_session_tickets off; ssl_ecdh_curve secp384r1; ssl_certificate /var/lib/dehydrated/certs/${WEBSITE}/fullchain.pem; ssl_certificate_key /var/lib/dehydrated/certs/${WEBSITE}/privkey.pem; ssl_protocols TLSv1.2 TLSv1.3; # ECDHE better than DHE (faster) ECDHE & DHE GCM better than CBC (attacks on AES) # Everything better than SHA1 (deprecated) # #ssl_ciphers 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA' ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384; ssl_prefer_server_ciphers on; #resolver 192.168.42.129 8.8.8.8 valid=300s; #resolver_timeout 5s; add_header Strict-Transport-Security "max-age=31536000 always"; add_header X-Frame-Options DENY; add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; access_log /var/log/nginx/${WEBSITE}_access.log; error_log /var/log/nginx/${WEBSITE}_error.log; auth_basic "Authentication Required"; auth_basic_user_file /etc/nginx/htpasswd.kibana; location / { proxy_pass http://localhost:5601; proxy_http_version 1.1; proxy_set_header Upgrade \$http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host \$host; proxy_cache_bypass \$http_upgrade; } } EOF # - Enable site ${WEBSITE} # - ln -s ../sites-available/${WEBSITE}.conf /etc/nginx/sites-enabled/ # - Create a basic authentication file with the openssl command: # - # - user: admin # - password: $E%R&T/Z(U # - echo "admin:$(openssl passwd -apr1 '$E%R&T/Z(U')" | sudo tee -a /etc/nginx/htpasswd.kiba # - Restart Nginx Webservice # - systemctl restart nginx # ========== # Install Logstash (logstash-oss) # ========== # The final step is to install Logstash using the apt package manager from # the official Elastic repository. # apt-get install logstash-oss # Start the Logstash service and set it to start automatically on boot: # systemctl restart logstash systemctl enable logstash # --- # Note: # The Logstash configuration depends on your personal preferences and the # plugins you will use. You can find more information about how to configure # Logstash here: # # https://www.elastic.co/guide/en/logstash/current/configuration.html # ---