Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How disable remote access in elasticsearch

When running a elasticsearch server. We can access www.example.com:9200

But i want block remote access only allow local access.

How to setting?

like image 257
Grant Chen Avatar asked Jul 02 '13 09:07

Grant Chen


2 Answers

Instead of disabling whole HTTP protocol by changing http.enabled in /etc/elasticsearch/elasticsearch.yml settings (because some of your APIs can use the HTTP endpoint which was my case), you can just set network.host: localhost in the same file.

This will make your :9200 HTTP access to be available only from your local machine/server.

like image 117
jtompl Avatar answered Oct 19 '22 08:10

jtompl


Elasticsearch allows you to disable the http endpoint just setting http.enabled to false in the settings. It also allows to have a local node which will only be reachable in the same jvm. On the other hand you are asking how to allow only local access to the rest endpoint, which is different and require the use of additional tools.

In fact, it's not a good idea to expose elasticsearch to the internet. I would use a proxy like apache or Nginx to limit the access to it and open for instance only some of the available endpoints, but that's needed only if you have external users that want to send messages directly to elasticsearch. Usually that's not the case. Or if you just want to deny access to it for all external users, because it's for instance only your website or application that needs access to it, just use a firewall and setup a proper rule to close the 9200 port.

like image 33
javanna Avatar answered Oct 19 '22 08:10

javanna