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

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

提交回复
热议问题