Question

I wanted to serve couchdb on port 80 using nginx. I basically setup the nginx conf files like this:

upstream couchdb {
    server 127.0.0.1:5984;
}

server {
    listen 0.0.0.0:80;
    server_name example.com;
    access_log /path/to/log/couchdb.log;

    location / {
        add_header 'Access-Control-Allow-Origin' '*';
        proxy_pass http://couchdb;
        proxy_set_header Host $host;
        proxy_redirect off;
    }
}

The configuration seems to work except for a particular case. When I type http://example.com/_utils/ I get to the couchdb instance, but if I type http://example.com/_utils (note missing trailing slash) I get nothing because I am being redirected to http://couchdb/_utils. Note that both http://example.com:5984/_utils/ and http://example.com:5984/_utils work fine.

My WAG is that the issue is with the nginx configuration but I am not sure how that is.

Was it helpful?

Solution

It seems the culprit is proxy_redirect off;. Why did you turn it off?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top