Return-Path: Delivered-To: apmail-incubator-couchdb-dev-archive@locus.apache.org Received: (qmail 81329 invoked from network); 3 Sep 2008 18:38:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Sep 2008 18:38:53 -0000 Received: (qmail 67121 invoked by uid 500); 3 Sep 2008 18:38:49 -0000 Delivered-To: apmail-incubator-couchdb-dev-archive@incubator.apache.org Received: (qmail 67090 invoked by uid 500); 3 Sep 2008 18:38:49 -0000 Mailing-List: contact couchdb-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-dev@incubator.apache.org Delivered-To: mailing list couchdb-dev@incubator.apache.org Received: (qmail 67079 invoked by uid 99); 3 Sep 2008 18:38:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Sep 2008 11:38:49 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=FS_REPLICA,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of adam.kocoloski@gmail.com designates 74.125.92.148 as permitted sender) Received: from [74.125.92.148] (HELO qw-out-1920.google.com) (74.125.92.148) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Sep 2008 18:37:50 +0000 Received: by qw-out-1920.google.com with SMTP id 4so337408qwk.54 for ; Wed, 03 Sep 2008 11:38:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:content-transfer-encoding:mime-version:subject:date :x-mailer; bh=cp46BLcM+6/LQRVqMMOPsj4P98plJ6jrJxAc3dMS5/Y=; b=M5KaIGgBEBGYu+R1OI9npOdiuaDaz/60fFuEfdkiqWl9h94Adi+yIU+zm7f+F+HCCQ zHP+v80orcdoGkAL/QqO/dgSwfRUZ9urtm4OLaYWyHOHw1UZ8fvG965+MxOoKDkLj9Ql GpDbTMn12VT5VW1ChQDXh1mCayf8S5UDjo02A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=hWcyObCDdenGDpOW0zKrCkYGJfVOwNGgIZCcY27mSrr1hQ00uFRc/AjLNlFqmKCYwJ 8Wh3OkT+M5GpDxn2Nh6FUZGvmSxymZpUFiCb3zXo3YkAVy5ot+Rui6xLYQQjo1UqvjFL YTJGyKMbtspieYQu5l+WT9aodJsXNcJ6pLB7g= Received: by 10.214.81.21 with SMTP id e21mr8163583qab.44.1220467090856; Wed, 03 Sep 2008 11:38:10 -0700 (PDT) Received: from COMPTON-SIX-SIXTY-NINE.MIT.EDU ( [18.109.7.158]) by mx.google.com with ESMTPS id 26sm10408303qwa.8.2008.09.03.11.38.09 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 03 Sep 2008 11:38:10 -0700 (PDT) Message-Id: <0D2EE974-228C-4C7E-A4DC-61CF9D9C8A9F@gmail.com> From: Adam Kocoloski To: couchdb-dev@incubator.apache.org Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v926) Subject: URL-decoding reverse proxy breaks remote replication Date: Wed, 3 Sep 2008 14:38:08 -0400 X-Mailer: Apple Mail (2.926) X-Virus-Checked: Checked by ClamAV on apache.org 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] ->