couchdb-best-practices
couchdb-best-practices copied to clipboard
Why is nginx not recommended as a proxy?
An issue with SSL termination (citation needed) /cc @janl
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 ;)
3caf71dffb054aa718133d6c54829570744e93e4
https://github.com/eHealthAfrica/ehealth-deployment/issues/151
Here is a another one: https://www.ruby-forum.com/topic/4412004 — Last time I checked this was still not resolved.
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