couchdb-best-practices icon indicating copy to clipboard operation
couchdb-best-practices copied to clipboard

Why is nginx not recommended as a proxy?

Open tlvince opened this issue 9 years ago • 5 comments

An issue with SSL termination (citation needed) /cc @janl

tlvince avatar May 05 '15 15:05 tlvince

Nginx encodes urls on the way through. So, for example, if you request http://my.couch.behind.nginx.com/mydb/foo%2Fbar it gets routed to CouchDB as /mydb/foo/bar, which is not what we want.

We can configure this mad behaviour away (by not appending a slash to the proxy_pass target :P) but there is no way to convince nginx not messing with the url when rewriting the proxy behind a subdirectory, eg http://my.couch.behind.nginx.com/_couchdb/mydb/foo%2Fbar

Just to mention one argument against nginx ;)

jo avatar May 05 '15 15:05 jo

3caf71dffb054aa718133d6c54829570744e93e4

jo avatar May 05 '15 15:05 jo

https://github.com/eHealthAfrica/ehealth-deployment/issues/151

jo avatar May 05 '15 16:05 jo

Here is a another one: https://www.ruby-forum.com/topic/4412004 — Last time I checked this was still not resolved.

janl avatar May 23 '15 16:05 janl

Just stumbled upon this issue, but I thought I'd post a solution that works (at least for my usecase):

For a CouchDB located at http://my.couch.behind.nginx.com/mydb/, I use the following nginx configuration (simplified)

    location /mydb {
      rewrite /mydb/(.*) /$1 break;
      proxy_pass                           http://127.0.0.1:5984;
  }

The solution came up when discussing the issue on stackoverflow

chrispahm avatar Apr 22 '20 10:04 chrispahm