CouchDB 复制在代理后面无法正常工作
注意:根据新信息进行了一些更新。旧的想法已添加为下面的评论。 注意:根据新信息(再次)进行了一些更新。旧的想法已添加为下面的注释(再次)。
我们在 Apache 反向代理后面的不同计算机上运行两个 CouchDB 实例。当尝试在两个实例之间进行复制时:(
curl -X POST http://user:pass@localhost/couchdb/_replicate -d '{ "source": "db1", "target": "http://user:[email protected]/couchdb/db1" }' --header "Content-Type: application/json"
我们开始使用curl来调试问题)
我们收到类似于以下内容的错误:
{"error":"case_clause","reason":"{error,\n {{bad_return_value,\n {invalid_json,\n <<\"<!DOCTYPE HTML PUBLIC \\\"-//IETF//DTD HTML 2.0//EN\\\">\\n<html><head>\\n<title>404 Not Found</title>\\n</head><body>\\n<h1>Not Found</h1>\\n<p>The requested URL /couchdb/db1/_local/01e935dcd2193b87af34c9b449ae2e20 was not found on this server.</p>\\n<hr>\\n<address>Apache/2.2.3 (Red Hat) Server at 10.1.100.59 Port 80</address>\\n</body></html>\\n\">>}},\n {child,undefined,\"01e935dcd2193b87af34c9b449ae2e20\",\n {gen_server,start_link,\n [couch_rep,\n [\"01e935dcd2193b87af34c9b449ae2e20\",\n {[{<<\"source\">>,<<\"db1\">>},\n {<<\"target\">>,\n <<\"http://user:[email protected]/couchdb/db1\">>}]},\n {user_ctx,<<\"user\">>,\n [<<\"_admin\">>],\n <<\"{couch_httpd_auth, default_authentication_handler}\">>}],\n []]},\n temporary,1,worker,\n [couch_rep]}}}"}
因此,经过进一步研究,apache似乎返回了此错误,而没有尝试访问CouchDB(根据日志文件)。需要明确的是,当输入以下 URL 时,
/couchdb/db1/_local/01e935dcd2193b87af34c9b449ae2e20
Apache 会将请求传递给 CouchDB 并返回 CouchDB 的 404 错误。另一方面,当复制发生时,实际传递的 URL 是
/couchdb/db1/_local%2F01e935dcd2193b87af34c9b449ae2e20
apache 确定为丢失文档的 URL,并返回自己的 404 错误,而没有将请求传递给 CouchDB。这至少给了我一些新的线索,但如果有人立即得到答案,我仍然可以使用帮助。
Note: Made some updates based on new information. Old ideas have been added as comments below.
Note: Made some updates (again) based on new information. Old ideas have been added as comments below (again).
We are running two instances of CouchDB on separate computers behind Apache reverse proxies. When attempting to replicate between the two instances:
curl -X POST http://user:pass@localhost/couchdb/_replicate -d '{ "source": "db1", "target": "http://user:[email protected]/couchdb/db1" }' --header "Content-Type: application/json"
(we started using curl to debug the problem)
we receive an error similar to:
{"error":"case_clause","reason":"{error,\n {{bad_return_value,\n {invalid_json,\n <<\"<!DOCTYPE HTML PUBLIC \\\"-//IETF//DTD HTML 2.0//EN\\\">\\n<html><head>\\n<title>404 Not Found</title>\\n</head><body>\\n<h1>Not Found</h1>\\n<p>The requested URL /couchdb/db1/_local/01e935dcd2193b87af34c9b449ae2e20 was not found on this server.</p>\\n<hr>\\n<address>Apache/2.2.3 (Red Hat) Server at 10.1.100.59 Port 80</address>\\n</body></html>\\n\">>}},\n {child,undefined,\"01e935dcd2193b87af34c9b449ae2e20\",\n {gen_server,start_link,\n [couch_rep,\n [\"01e935dcd2193b87af34c9b449ae2e20\",\n {[{<<\"source\">>,<<\"db1\">>},\n {<<\"target\">>,\n <<\"http://user:[email protected]/couchdb/db1\">>}]},\n {user_ctx,<<\"user\">>,\n [<<\"_admin\">>],\n <<\"{couch_httpd_auth, default_authentication_handler}\">>}],\n []]},\n temporary,1,worker,\n [couch_rep]}}}"}
So after further research it appears that apache returns this error without attempting to access CouchDB (according to the log files). To be clear when fed the following URL
/couchdb/db1/_local/01e935dcd2193b87af34c9b449ae2e20
Apache passes the request to CouchDB and returns CouchDB's 404 error. On the other hand when replication occurs the URL actually being passed is
/couchdb/db1/_local%2F01e935dcd2193b87af34c9b449ae2e20
which apache determines is a missing document and returns its own 404 error for without ever passing the request to CouchDB. This at least gives me some new leads but I could still use help if anyone has an answer offhand.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
源 CouchDB (localhost) 告诉您远程 URL 无效。源接收的是 Apache httpd 代理的 file-not-found 响应,而不是 CouchDB 响应。
不幸的是,您可能需要进行一些反向代理故障排除。我的第一个猜测是源发送到目标的
Host
标头。也许这与您直接从第三个位置连接时有所不同?最后,我想您可能知道这一点,但该路径
不是标准的 CouchDB 路径。当 CouchDB 看到请求时,它应该已删除
/couchdb
,因此查询是针对名为的数据库中名为
。_local%2f...
的文档>db1顺便说一句,不要让代理在到达沙发之前修改路径,这一点非常重要。特别是,如果您发送
%2f
,那么 CouchDB 最好接收%2f
,如果您发送/
,那么 CouchDB 最好接收/
。The source CouchDB (localhost) is telling you that the remote URL was invalid. Instead of a CouchDB response, the source is receiving the Apache httpd proxy's file-not-found response.
Unfortunately, you may have some reverse-proxy troubleshooting to do. My first guess is the
Host
header the source is sending to the target. Perhaps it's different from when you connect directly from a third location?Finally, I think you probably know this, but the path
Is not a standard CouchDB path. By the time CouchDB sees a request, it should have the
/couchdb
stripped, so the query is for a document called_local%2f...
in the database calleddb1
.Incidentally, it is very important not to let the proxy modify the paths before they hit couch. In particular, if you send
%2f
then CouchDB had better receive%2f
and if you send/
then CouchDB had better receive/
.来自官方文档...
请注意,理论上支持 HTTPS 代理,但在 1.0.1 中不起作用。这是因为 1.0.1 附带 ibrowse 版本 1.5.5。 trunk 中的 CouchDB 版本(基于 1.1)随 ibrowse 版本 1.6.2 一起提供。稍后的 ibrowse 包含针对 HTTPS 代理的修复。
你能看到涉及哪个版本的 ibrowse 吗?也许更新那个版本?
From official documentation...
Note that HTTPS proxies are in theory supported but do not work in 1.0.1. This is because 1.0.1 ships with ibrowse version 1.5.5. The CouchDB version in trunk (from where 1.1 will be based) ships with ibrowse version 1.6.2. This later ibrowse contains fixes for HTTPS proxies.
Can you see which version of ibrowse is involved? Maybe update that ver?
我的另一个想法是关于 SSL 证书。如果您没有,我知道您没有:),那么从技术上讲,您的 SSL 操作是错误的。在java中,我们知道有一些方法可以解决这个问题,但也许尝试放入适当的证书,因为所有SSL内容基本上都涉及证书。
Another thought I have is with regard to the SSL certs. If you don't have any, and I know you don't :), then technically you're doing SSL wrong. In java we know there are ways around this, but maybe try putting in proper certs since all SSL stuff basically involves certs.
对于我最后的贡献(今天),我想说您是否浏览过这份看起来高度相关的文档?
http://wiki.apache.org/couchdb/Apache_As_a_Reverse_Proxy
And for my last contribution (today) I would say have you looked through this document which seems highly relevant?
http://wiki.apache.org/couchdb/Apache_As_a_Reverse_Proxy
我写这个答案是希望能够帮助那些可能已经在这个问题上苦苦挣扎了一个多星期的人:
我安装了 couchdb v3.1.1
我不得不在 IIS 上启用/安装两个模块以使其在代理上工作:
我必须更改 SSL 的设置:
另外我已经安装
Microsoft Visual C++ 2015-2019 和 2010 可再发行版
使 couchdb 服务无需重新启动即可运行。
希望有帮助。
I am writing this answer with the hope to help someone who might have been struggling with this issue for more than a week:
I have couchdb v3.1.1 installed
I was obliged to enable/install two modules on IIS to make it work on a proxy:
I had to change the settings of SSL:
Additionally I have installed
Microsoft Visual C++ 2015-2019 and 2010 Redistributable
to make couchdb service run without restarting.
Hope it helps.