我希望通过使用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"}
感谢任何帮助。