How do I enable remote access/request in Elasticsearch 2.0?

前端 未结 12 708
醉酒成梦
醉酒成梦 2020-12-22 22:09

Starting from v2.0 Elasticsearch is listening only on localhost by default, but I\'d like to make request outside localhost.

For example, a request like this is allo

相关标签:
12条回答
  • 2020-12-22 22:49

    In /etc/elasticsearch/elasticsearch.yml:

    network.host: 0.0.0.0
    network.bind_host: 0.0.0.0
    network.publish_host: 0.0.0.0
    
    0 讨论(0)
  • 2020-12-22 22:54

    Rename the elasticsearch.yml file to elasticsearch.json inside config folder and add:

    {
        "network" : {
            "host" : "10.0.0.4"
        }
    }
    

    Another option is to provide the settings externally either using the ES_JAVA_OPTS or as parameters to the elasticsearch command, for example:

    $ elasticsearch -Des.network.host=10.0.0.4

    Another option is to set es.default. prefix instead of es. prefix, which means the default setting will be used only if not explicitly set in the configuration file.

    Another option is to use the ${...} notation within the configuration file which will resolve to an environment setting, for example:

    {
        "network" : {
            "host" : "${ES_NET_HOST}"
        }
    }
    

    The location of the configuration file can be set externally using a system property:

    $ elasticsearch -Des.config=/path/to/config/file

    For more info, check out https://www.elastic.co/guide/en/elasticsearch/reference/1.4/setup-configuration.html

    0 讨论(0)
  • 2020-12-22 22:56

    In config/elasticsearch.yml put

    network.host: 0.0.0.0
    
    0 讨论(0)
  • 2020-12-22 22:57

    In config/elasticsearch.yml, put network.host: 0.0.0.0 as @arsent said. And also add Inbound Rule in firewall for your ElasticSearch port(9200 ByDefault).

    It worked in ElasticSearch version 2.3.0

    0 讨论(0)
  • 2020-12-22 23:00

    In the remote machine where elasticsearch is installed just add the below two configurations in /etc/elasticsearch/elasticsearch.yml

    network.host: xx.xx.xx.xx #remote elastic machine's internal IP
    discovery.type: single-node
    

    Tested on elasticsearch 6.8.3 and AWS EC2 Linux AMI as remote machine

    0 讨论(0)
  • 2020-12-22 23:02

    By default http transport and internal elasticsearch transport only listens to localhost. If you want to access Elasticsearch from the host other than localhost then try adding following configurations in config/elasticsearch.yml.

    transport.host: localhost 
    transport.tcp.port: 9300 
    http.port: 9200
    network.host: 0.0.0.0
    

    Here, network.host as 0.0.0.0 allow access from any host within the network.

    0 讨论(0)
提交回复
热议问题