Define username and password for access to elasticsearch database

Already, I worked with MySQL database with PHP. There, for security reason, we needed username and password for access to the database. I want to know how to specify username and password for elasticsearch database. Please help.
Thanks a lot

I believe you either proxy the requests to port 9200 (or whatever you use) via Haproxy or a web server (i.e. Nginx) and define authentication, or you can install X-Pack and use Kibana management for roles, users, and permissions. Elasticsearch alone won't do it so you either have to use the plugins or configure your own proxy to restrict traffic to the server.

Another suggestion if you don't want to use X-Pack or configure your own reverse proxy is to leverage an API Gateway. I like Kong, but that's one more thing for you to manage so use at your discretion. The nice thing is you can manage all your access to all your APIs in one place so check out Kong too. You would want to block public traffic to port 9200 and route traffic via reverse proxy to a URI pattern or domain configured in Kong that can speak to ES on private internal network.

Otherwise, as noted: https://www.elastic.co/guide/en/x-pack/current/elasticsearch-security.html

Thanks a lot. Sorry I am very beginner in elasticsearch and even in PHP!! because that I did not understand your answer accurately (it was so heavy for me :slight_smile: ). May you please simplify your answer so that I can set authentication alone? is there any tutorial for this goal?
I run elasticsearch-php 6.0 on my laptop with xampp 7.0.

The short answer is Elasticsearch does not have built in user/password management like MySQL database.

You need to install X-Pack and use their security plugin

OR

You need to secure your Elasticsearch instance using firewall (blocking external access to ports), and then reverse proxy requests to it with a web server, API gateway, or load balancer.

Since you said you're a beginner, I would suggest you install the X-Pack and use the built-in security and manage it with Kibana. You'll need to follow instructions via Elastic's site to install the extra tools.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.