我在我的根服务器上安装了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
有人可以帮我这个吗?
答案 0 :(得分:0)
好的,我自己发现了这个问题: 缺少apache模块(代理的子模块)。现在上面的解决方案完美无瑕。