简体   繁体   中英

CouchDB replication is not working properly behind a proxy

Made some updates based on new information. 根据新信息进行了一些更新。 Old ideas have been added as comments below. 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:pass@10.1.100.59/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:pass@10.1.100.59/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.

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

/couchdb/db1/_local%2F01e935dcd2193b87af34c9b449ae2e20

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 called db1 .

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 / .

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?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM