我在我的根服务器上安装了 couchdb。现在我试图通过代理只允许对我的数据库的 PUT 请求。但我无法让它工作。我尝试了什么:
(.htaccess)
SetEnvIf Request_URI acraproxy acraproxy
RequestHeader set Authorization "Basic base64credentials" env=acraproxy
RewriteEngine On
RewriteRule ^acraproxy/(.*)$ http://localhost:5984/mydatabase/_design/acra-storage/_update/report/$1 [P]
我总是收到错误代码 405。我还尝试使用这样的 php 脚本:
<?php
$COUCH_INSTANCE = 'http://www.acmecouch.com'; // URL of your CouchDB instance
$COUCH_PORT = 80; // Port of your CouchDB instance
$REPORTER_USER = 'acra'; // Username of the reporter user
$REPORTER_PASSWORD = 'r3p0rts'; // Password for the reporter user
$APPNAME = 'myapp'; // the name of your app, same as defined when pushing your own acra-storage couchapp instance
if($_SERVER['REQUEST_METHOD'] === 'PUT') {
$curl = curl_init($COUCH_INSTANCE.'/acra-'.$APPNAME.'/_design/acra-storage/_update/report/'.$_GET["reportid"]);
curl_setopt($curl, CURLOPT_PORT, $COUCH_PORT);
curl_setopt($curl, CURLOPT_USERPWD, $REPORTER_USER . ":" . $REPORTER_PASSWORD);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_PUT, true);
curl_setopt($curl, CURLOPT_INFILE, fopen("php://input","r"));
curl_setopt($curl, CURLOPT_INFILESIZE, $_SERVER['CONTENT_LENGTH']);
$result = curl_exec($curl);
echo $result;
} else {
// If not a PUT request, just get the root of the CouchDB.
// This allows to check with a browser that the path from your php server
// to the couch instance is operational.
$curl = curl_init($COUCH_INSTANCE);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curl);
echo $result;
}
?>
但这会因 php 错误而失败:
CURLOPT_FOLLOWLOCATION
cannot be activated when an open_basedir is set
我遵循了本教程:https ://github.com/ACRA/acralyzer/wiki/Setting-up-a-reverse-proxy
有人可以帮我弄这个吗?