# Generate passwords: # You can use an online htpasswd tool, a python script or the openssl package on your distro. # $ printf "user:$(openssl password -crypt user)\n" >> htpasswd # $ printf "admin:$(openssl password -crypt admin)\n" >> htpasswd # # Install the Nginx with Lua support ("openresty"): # To Run nginx (make sure you have the lua, config and htpasswd file): # $ /usr/local/openresty/nginx/sbin/nginx -c /etc/nginx/conf/nginx_authorize_by_lua.conf worker_processes 1; error_log logs/lua.log notice; events { worker_connections 1024; } http { upstream elasticsearch { server 127.0.0.1:9200; keepalive 15; } server { listen 8080; location / { auth_basic "Protected Elasticsearch"; auth_basic_user_file "/usr/local/openresty/nginx/auth/htpasswd"; access_by_lua_file '/usr/local/openresty/nginx/conf/authorize.lua'; proxy_pass http://elasticsearch; proxy_redirect off; proxy_buffering off; proxy_http_version 1.1; proxy_set_header Connection "Keep-Alive"; proxy_set_header Proxy-Connection "Keep-Alive"; } } }