我想通过使用 proxy_pass 在我的域上运行的 NGINX 公开 Cloudant 的一些 couchdb 功能。到目前为止,我已经解决了一些问题(如下所述),但就授权而言,我被困住了。有没有人有任何提示?
location /couchdb {
rewrite /couchdb/(.*) /$1 break; #chop off start of this url
proxy_redirect off
proxy_buffering off;
proxy_set_header Host myusername.cloudant.com;
# cannot use $host! must specify my vhost on cloudant
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Authorization "Basic base64-encode(username:password)";
proxy_pass http://myusername.cloudant.com$request_uri;
# must use a variable in this url so that the domain is looked up late.
# otherwise nginx will fail to start about half the time because of resolver issues
# (unknown why though)
}
使用此设置,我可以成功代理到 Cloudant,但我总是收到禁止响应。例如,这个请求:
http://mydomain/couchdb/my-cloudant-db
返回
{"error":"forbidden", "reason":"_reader access is required for this request"}
谢谢你的帮助。