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

前端 未结 12 709
醉酒成梦
醉酒成梦 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 23:02

    As @arsent mentioned add that ip address to the config file:

    sudo nano /etc/elasticsearch/elasticsearch.yml
    

    Jay also added an important point - if you're using a firewall, remember to add a rule allowing traffic to that port.

    If you want to allow a master server to access ES over http, then add a rule allowing access to only from that particular address. For example, say you are using ufw, then run this command to add your port:

    sudo ufw allow from xxx.xxx.xxx.xxx to any port zzzz
    

    Replace xxx.xxx.xxx.xxx with your master server IP address and zzzz with the port you configured in config/elasticsearch.yml

    It is recommended to use a custom port and not keep the default 9200

    To test it, SSH into your master server and ping the ES ip with the correct port to see if you get a response:

    curl -X GET 'http://xxx.xxx.xxx.xxx:zzzz'
    

    You can also verify ES is inaccessible from other IPs by trying it with your browser.

    There's an excellent article that shows how to set up ES on Ubuntu on DigitalOcean

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

    For ElasticSearch 7.8 and up

    Check if you're on single node. add following line

    cluster.initial_master_nodes: node-1
    

    To access the Elasticsearch server from another computer or application, make the following changes to the node’s C:\ProgramData\Elastic\Elasticsearch\config\elasticsearch.yml file:

    Add following lines

    network.host: ["0.0.0.0", 127.0.0.1", "[::1]"]
    network.bind_host: 0.0.0.0
    network.publish_host: 0.0.0.0
    http.host: 0.0.0.0
    

    Some time you might need to Enable CORS

    http.cors.enabled : true
    http.cors.allow-origin : "*"
    http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
    http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type, Content-Length
    

    Here is my full yml file

    bootstrap.memory_lock: false
    cluster.name: elasticsearch
    http.port: 9200
    node.data: true
    node.ingest: true
    node.master: true
    node.max_local_storage_nodes: 1
    cluster.initial_master_nodes: node-1
    node.name: ITDEV
    path.data: C:\ProgramData\Elastic\Elasticsearch\data
    path.logs: C:\ProgramData\Elastic\Elasticsearch\logs
    transport.tcp.port: 9300
    xpack.license.self_generated.type: basic
    xpack.security.enabled: false
    network.host: ["0.0.0.0", 127.0.0.1", "[::1]"]
    network.bind_host: 0.0.0.0
    network.publish_host: 0.0.0.0
    http.host: 0.0.0.0
    http.cors.enabled : true
    http.cors.allow-origin : "*"
    http.cors.allow-methods : OPTIONS, HEAD, GET, POST, PUT, DELETE
    http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type, Content-Length
    
    0 讨论(0)
  • 2020-12-22 23:04

    Using Windows 10 and standalone Elasticsearch 7, putting this in elasticsearch.yml solve the issue:

    network.host: 0.0.0.0 discovery.type: single-node

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

    Replace localhost with 0.0.0.0 in two places.

    1. Goto /etc/elasticsearch/elasticsearch.yml. Look for value in network.host and change it to 0.0.0.0

    2. This is step if you are using Kibana. Goto /etc/kibana/kibana.yml. Look for value in server.host and change it to 0.0.0.0

    Now you access remotely access with IP address and host.

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

    In /etc/elasticsearch/elasticsearch.yml set the following value:

    network.host: [ localhost, _site_ ]

    This option allows you to access from both the localhost and from all computers on the local network (192.168.X.X), but not from outside.
    Read more about this and other options read the documentation

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

    Apart from setting network.host : 0.0.0.0

    there might be need to set following params

    node.name: elasticsearch-node-1
    
    cluster.initial_master_nodes: ["elasticsearch-node-1"]
    

    All setting go in elasticsearch/elasticsearch.yml

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