Hi, I installed CouchDB behind nginx the other day and noticed that
remote replication didn't work. The problem seems to be that
a) CouchDB stores the replication history in a local doc with an ID
formed from the URL-encoded paths to the source and target DBs,
b) nginx decodes all %2Fs in the URLs it processes, and
c) couch_httpd chokes on a GET request for the replication history doc
using the decoded URL delivered by nginx.
My workaround was to encode "/" as "|" in the ID of the replication
history document. It seemed simpler than doing extra special-casing
in couch_httpd to handle decoded "/" characters in replication docIDs,
and I didn't see any way to turn off URL decoding in nginx. Best,
Adam
--- a/trunk/src/couchdb/couch_rep.erl
+++ b/trunk/src/couchdb/couch_rep.erl
@@ -28,6 +28,9 @@ url_encode([H|T]) ->
[H|url_encode(T)];
H == $_; H == $.; H == $-; H == $: ->
[H|url_encode(T)];
+ % nginx will decode the %2F which makes couch_httpd blow up
+ H == $/ ->
+ [$||url_encode(T)];
true ->
case lists:flatten(io_lib:format("~.16.0B", [H])) of
[X, Y] ->