CouchDB 反向代理

CouchDB reverse proxy

我在根服务器上安装了 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/ [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

有人可以帮我解决这个问题吗?

好的,我自己发现了问题: 缺少 apache 模块(代理的子模块)。现在以上解决方案完美无缺。