普通网友 2017-09-30 10:10
浏览 427
已采纳

无法连接到我的代理elasticsearch节点

I'm having issues with connecting from my Go client to my es node.

I have elasticsearch behind an nginx proxy that sets basic auth. All settings are default in ES besides memory.

Via browser it works wonderfully, but not via this client: https://github.com/olivere/elastic

I read the docs and it says it uses the /_nodes/http api to connect. Now this is probably where I did something wrong because the response from that api looks like this:

{
  "_nodes" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "cluster_name" : "elasticsearch",
  "nodes" : {
    "u6TqFjAvRBa3_4FndfKh4w" : {
      "name" : "u6TqFjA",
      "transport_address" : "127.0.0.1:9300",
      "host" : "127.0.0.1",
      "ip" : "127.0.0.1",
      "version" : "5.6.2",
      "build_hash" : "57e20f3",
      "roles" : [
        "master",
        "data",
        "ingest"
      ],
      "http" : {
        "bound_address" : [
          "[::1]:9200",
          "127.0.0.1:9200"
        ],
        "publish_address" : "127.0.0.1:9200",
        "max_content_length_in_bytes" : 104857600
      }
    }
  }
}

I'm guessing I have to set the IPs to my actual IP/domain (my domain is like es01.somedomain.com)

So how do i correctly configure elastisearch so that my go client can connect?

My config files for nginx look similar to this: https://www.elastic.co/blog/playing-http-tricks-nginx

Edit: I found a temporary solution by setting elastic.SetSniff(false) in the Options for the client, but I think that means I can't scale ES horizontally. So still looking for an alternative.

  • 写回答

1条回答 默认 最新

  • dongzhong5573 2017-10-02 14:04
    关注

    You are looking for the HTTP options, specifically http.publish_host and http.publish_port, which should be set to the publicly reachable address and port of the Nginx server proxying the ES node.

    Note that with Elasticsearch listening on 127.0.0.1:9300 for the transport, you won't be able to form a cluster with nodes on other hosts. The transport can be configured similarly with the transport options.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 chaquopy python 安卓
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题