普通网友 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 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题
  • ¥15 FPGA-SRIO初始化失败
  • ¥15 MapReduce实现倒排索引失败
  • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
  • ¥15 找一位技术过硬的游戏pj程序员
  • ¥15 matlab生成电测深三层曲线模型代码