【问题标题】:ES not listening to external requestsES 不监听外部请求
【发布时间】:2015-12-27 12:59:40
【问题描述】:

我有一个运行 elasticsearch 的 e2 ubuntu 实例,虽然它在本地运行良好,但我无法使用 curl http://ipaddress:9200/ 从 Windows pc 连接(错误是“无法连接到远程服务器”)。

我已经在同一个 ubuntu 实例上设置了 Apache,curl http://ipaddress:80/ 在同一个 Windows 机器上工作,我可以毫无问题地 ping 实例。 我的亚马逊安全组允许从所有 IP 地址对所有端口进行 tcp 访问。

我认为这是一个 ES 配置问题,尽管我添加到 elasticsearch.yml 的唯一行是:

http.cors.enabled: true
http.cors.allow-origin: "*"

我在运行 netstat 时注意到一些奇怪的事情,端口 9200 和 9300(ES 端口)的本地地址中有一个 1 - 这会阻止我的外部请求,如果是,我该如何更改?

   ubuntu@ESServer$ netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0    448 (AWS PRIVATE IP):22     (MY IP):63572           ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 ::1:9200                :::*                    LISTEN
tcp6       0      0 127.0.0.1:9200          :::*                    LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 ::1:9300                :::*                    LISTEN
tcp6       0      0 127.0.0.1:9300          :::*                    LISTEN

【问题讨论】:

  • 您可以上网吗?你有外网IP吗?
  • 上网没问题,我可以访问80端口。我在curl命令中使用外部IP
  • 您是否启用了 IPTables?你能显示iptables -L的输出吗?
  • sudo iptables -L Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
  • 对格式化表示歉意。基本上,iptables 是空的

标签: ubuntu elasticsearch amazon-ec2 netstat


【解决方案1】:

您的 elasticsearch 进程似乎绑定到 localhost。尝试像这样运行它:

bin/elasticsearch --network.host _non_loopback_

从 2.0 开始,elasticsearch 绑定到 localhost。因此,您无法访问它。

this blog post 中解释了此更改背后的原因

【讨论】:

  • 谢谢!我实际上将 elasticsearch.yml 中的 network.host 设置更改为 0:0:0:0 并在几分钟前重新启动了实例,这很有效。但是,在阅读下面的文档后,我已将此标记为答案,很明显您的方法也可以。
猜你喜欢
  • 2017-08-11
  • 2013-05-21
  • 1970-01-01
  • 1970-01-01
  • 2019-01-04
  • 1970-01-01
  • 2014-01-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多