我试图在我的CentOS 7服务器上设置CouchDB 2.0实例。 我已将它安装并作为systemd服务运行,当我使用127.0.0.1或0.0.0.0从服务器访问它时,它会以友好的hello world消息进行响应
$ curl 127.0.0.1:5984
{"couchdb":"Welcome","version":"2.0.0","vendor":{"name":"The Apache Software Foundation"}}
$ curl 0.0.0.0:5984
{"couchdb":"Welcome","version":"2.0.0","vendor":{"name":"The Apache Software Foundation"}}
在我的local.ini文件中我将bind_address绑定到0.0.0.0
[httpd]
bind_address = 0.0.0.0
我的理解是,如果我有这个绑定地址,我可以从防火墙中打开的任何IP地址连接到端口5984
我使用firewalld作为防火墙,我已将其配置为打开端口5984 通过列出公共区域的配置来确认此配置:
$ sudo firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: couchdb2 dhcpv6-client http https ssh
ports: 443/tcp 5984/tcp
protocols:
masquerade: no
forward-ports:
sourceports:
icmp-blocks:
rich rules:
我还在/etc/firewalld/services/couchdb2.xml上用XML创建了一个名为couchdb2的服务:
<service>
<short>couchdb2</short>
<description>CouchDB 2.0 Instance</description>
<port protocol="tcp" port="5984"/>
</service>
根据我对firewalld的了解,我现在可以在5984上接收连接
但是当我从笔记本电脑上卷曲时,我的连接被拒绝了:
$ curl my-server:5984 --verbose
* Rebuilt URL to: my-server:5984/
* Trying <my-ip>...
* connect to <my-ip> port 5984 failed: Connection refused
* Failed to connect to my-server port 5984: Connection refused
* Closing connection 0
当我通过127.0.0.1或0.0.0.0本地连接到couchdb实例时,我可以在couchdb日志中看到200响应:
$ sudo journalctl -u couchdb2
...
[notice] 2017-06-06T00:35:01.159244Z couchdb@localhost <0.3328.0> 222d655c69 0.0.0.0:5984 127.0.0.1 undefined GET / 200 ok 28
[notice] 2017-06-06T00:37:21.819298Z couchdb@localhost <0.5598.0> 2f8986d14b 127.0.0.1:5984 127.0.0.1 undefined GET / 200 ok 1
但是当我从笔记本电脑中卷曲时,在couchdb日志中没有显示Connection Refused错误 这告诉我,问题可能是防火墙而不是CouchDB,但我不确定。 连接拒绝始终是防火墙吗?如果CouchDB实例有问题,我会得到一些其他错误吗? 据我所知,CouchDB和firewalld都配置正确,但它不能像我预期的那样工作。 无论您是否知道问题,或者您是否可以帮助我辨别问题是否与CouchDB或firewalld相关,我们将不胜感激。