0

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

5
  • Hmm, the /_session request 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?
    – USD Matt
    Jan 26, 2018 at 13:05
  • Yes, I forget to mention that adding proxy blocks for /_session, /_all_dbs, etc solves those 404 issues, so we can be pretty sure that this hack will work if nothing would.
    – ceremcem
    Jan 26, 2018 at 13:08
  • For the workaround: The mentioned workaround does not function flawlessly. Fauxton is fully and correctly rendered but when a new database is being created (for example, foo) the target url is calculated as https://example.com/foo instead of https://example.com/couchdb/foo, so no database can be created. Only workaround is creating an ssh tunnel for Fauxton at the moment.
    – ceremcem
    Jan 26, 2018 at 18:43
  • 1
    I have it working with proxy_buffering off; Sep 23, 2019 at 10:07
  • It looks like we have similar problems. See if this helps: serverfault.com/questions/994736/…
    – W1M0R
    Dec 7, 2019 at 19:34

0

You must log in to answer this question.

Browse other questions tagged .