Fauxton (CouchDB manager) behind Nginx is not fully working. Following Nginx block from CouchDB Wiki is not working at all:
location /couchdb { rewrite /couchdb/(.*) /$1 break; proxy_pass http://localhost:5984; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } When I change the location /couchdb part with location ^~ /couchdb, it starts working by displaying Fauxton at least.
Inspection (Chromium Inspector) shows the problem as the /_session url is requested from https://example.com/_session instead of https://example.com/couchdb/_session, which means that Fauxton can not determine correctly that it is served within a subdirectory (adding a proxy block for /_session url solves the 404 issue) That's why I dumped the request on CouchDB host with nc -l -p 5984 to see what the headers are set to:
GET /_utils/ HTTP/1.1 Host: example.com X-Forwarded-For: 127.0.0.1 X-Real-IP: 127.0.0.1 I'm not sure if X-Forwarded-For header is set correctly or not. What is the expected headers here? How can I determine if the problem is with my Nginx setup or there is another issue with - for example - my firewall (iptables) settings?
Edit
Possible problem is with Fauxton, not with CouchDB: https://github.com/apache/couchdb-fauxton/issues/944
/_sessionrequest does suggest something is using absolute urls, which obviously won't get proxied. The wiki does mention that Futon won't work (or at least didn't at the time) with links to a patch, nothing about Fauxton though. (I don't use CouchDB so have no real idea what any of this is...) Ugly hack, but have you tried adding proxy blocks for any urls that you are seeing bad requests for, assuming that path isn't used on the main nginx server. (i.e. a proxy section to pass/_session/(.*)through to CouchDB?/_session,/_all_dbs, etc solves those 404 issues, so we can be pretty sure that this hack will work if nothing would.foo) the target url is calculated ashttps://example.com/fooinstead ofhttps://example.com/couchdb/foo, so no database can be created. Only workaround is creating an ssh tunnel for Fauxton at the moment.proxy_buffering off;