Nginx – CouchDB test suite gives 502 Bad Gateway behind Nginx proxy

couchdbnginxPROXY

I installed CouchDB on my Ubuntu server from the stable PPA. Then I put this in my nginx.conf:

server {
    listen 80;
    server_name couchdb.mydomain.com;

    location / {
        proxy_pass http://127.0.0.1:5984;
    }
}

setting up a subdomain to access Futon. When I go to couchdb.mydomain.com/_utils and run the CouchDB test suite, Nginx gives 502 Bad Gateway errors. Any ideas on what would be causing this? Is it possible to know what url the test suite is trying to go to?

Best Answer

On Firefox, you can use the livehttpheaders addon to watch the headers and try to diagnose your problem.

On Chrome, you can go to chrome://net-internals and do the same on the events tab.

In any case, it seems that test fails behind proxy problem is a known one:

Known Test Suite issue with reverse proxy from subdirectory URL

If the reverse proxy configuration also rewrites the URL for a subdirectory, the test suite will fail because it relies on the absolute root path for HTTP requests. This is a known issue and a patch has been submitted by Jack Moffitt at https://issues.apache.org/jira/browse/COUCHDB-321.