我无法使用本地机器的IP地址连接到我的数字海洋液滴上的ElasticSearch。
-
I got the IP Address by: Terminal>
ipconfig getifaddr en0
-有了这个结果,我们说:100.888.777.99 -
我登录到我的滴运行:
ssh username@111.222.3.444
-
更新我的UFW规则运行:
sudo ufw allow 9200 from 100.888.777.99
-
从我的本地机器我运行:
curl -X GET 'http://111.222.3.444:9200'
-
收到:
curl: (7) Failed to connect to 111.222.3.444 port 9200: Operation timed out
我做错了什么?
我尝试过的事情:
- 修改网络。elasticsearch/elasticsearch.yml中的主机变量
network.host: 0.0.0.0
(这也是一个安全风险,因为ip地址是允许的) - 重新启动服务器
sudo /etc/init.d/elasticsearch restart
- 添加更多变量到elasticsearch/elasticsearch.yml
transport.host: localhost
transport.tcp.port: 9300
http.port: 9200
我发现当我更改UFW规则以允许所有连接到端口9200时,我能够从我的本地机器连接到ElasticSearch,但没有这个,它将无法连接。
sudo ufw allow 9200
经过一番深入研究,我发现问题是终端返回的IP地址不是正确的使用。我必须使用公共IP地址这是我从https://www.whatismyip.com/上得到的,你也可以通过:
Terminal>curl ifconfig.me
所以当我删除旧的UFW规则:9200 ALLOW IN 100.888.777.99
并使用公共IP地址:sudo ufw allow 9200 from Public_IP_Address
进行连接。
我仍然不知道为什么我的机器的IP地址不工作,虽然…