回答:
nginxはLDAPを実行しませんxsendfile。LDAP認証を処理するには、作成したサードパーティのスクリプトを使用する必要があります
nginx用の非公式LDAPモジュール:nginx-auth-ldapがあります。
nginx-auth-ldap使用できるサードパーティのモジュールがあります。まだ試していませんが、後で回答を更新することがあります。
のドキュメントでX-accelは、ページがヘッダーを使用してnginxにファイルを提供する可能性があることを説明しています(PHPまたはdjangoor rubyまたはor - or -not-as-efficient-as-nginx-stack-hereではありません)。
例:ワークフロー:
/download.php?path=/data/file1.txt、download.phpリターンWWW-Authenticate+ 401 Unauthorized、/download.php?path=/data/file1.txtが、現在nginxは認証情報を持っている、nginx通過してもよい$remote_userと$http_authorizationするfastcgiスクリプト、download.php認証を行い403 Forbidden、ヘッダーX-Accel-Redirectヘッダーを返すか設定するかを決定します。internal場所の設定を使用X-Accelして静的アセットを提供することもできますが、ここでのユースケースは、リクエストを認証することinternalです。そのため、を使用しています。
location /protected/data/ {
    internal;
    alias /path/to/data/files/;
}
さあ行こう:
location /download.php$ {
    fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_param SCRIPT_FILENAME /scripts/download.php;
    fastcgi_param PHP_AUTH_USER $remote_user;
    fastcgi_param PHP_AUTH_PW $http_authorization;
    include fastcgi_params;
}
注意:PHPスクリプトはPHP_AUTH_USERおよびを使用しますPHP_AUTH_PW。これはによってキャプチャさnginxれます。そのため、PHPスクリプトでそれらを使用するには、明示的に提供する必要があります。
私の使用例では、システムにインストールphp-fpmしphp-ldapました。
これはまともな認証機能です:
function authenticate() {
    // I'm watching you.
    error_log("authreq: " . $_SERVER['REMOTE_ADDR']);
    // mark that we're seeing the login box.
    $_SESSION['AUTH'] = 1;
    // browser shows login box
    Header("WWW-Authenticate: Basic realm=LDAP credentials.");
    Header("HTTP/1.0 401 Unauthorized");
    die('Unauthorized.');
}
禁止されたアクセスの適切なコードパスは次のとおりです。
function forbidden() {
    error_log("forbidden: " . $_SERVER['REMOTE_ADDR'] . ', user: ' . $_SERVER['PHP_AUTH_USER']);
    // avoid brute force attacks
    sleep(rand(0, 3));
    // re-display login form
    session_destroy();
    // don't give too much info (e.g. user does not exist / password is wrong)
    Header("HTTP/1.0 403 Forbidden");
    // yes I did put the same message.
    die('Unauthorized.');
}
そしてLDAP認証の要点として:
function ldap_auth() {
    $ldap_server = 'ldap://ldap.example.com/';
    $ldap_domain = 'dc=example,dc=com';
    $ldap_userbase = 'ou=Users,' . $ldap_domain;
    $ldap_user = 'uid=' . $_SERVER['PHP_AUTH_USER'] . ',' . $ldap_userbase;
    $ldap_pass = $_SERVER['PHP_AUTH_PW'];
    // connect to ldap server
    $ldapconn = ldap_connect($ldap_server)
        or die("Could not connect to LDAP server.");
    ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3) ;
    if ($ldapconn) {
        // try to bind/authenticate against ldap
        $ldapbind = @ldap_bind($ldapconn, $ldap_user, $ldap_pass) || forbidden();
        // "LDAP bind successful...";
        error_log("success: " . $_SERVER['REMOTE_ADDR'] . ', user: ' . $_SERVER['PHP_AUTH_USER']);
    }
    ldap_close($ldapconn);
}
ここにリクエストURIを使用するスクリプトの本体があります。
if (@$_SESSION['AUTH'] != 1) {
    authenticate();
}
if (empty($_SERVER['PHP_AUTH_USER'])) {
    authenticate();
}
// check credentials on each access
ldap_auth();
// Get requested file name
// you can use the query string or a parameter
// or the full request uri if you like.
$path = $_GET["path"];
error_log("serving: " . $_SERVER['REMOTE_ADDR'] . ', user: ' . $_SERVER['PHP_AUTH_USER'] . ', path: ' . $path);
header("Content-Type: ", true);
header("X-Accel-Redirect: /protected" . $path);
location /protected/data/ {
    internal;
    autoindex on;
    alias /path/to/data/files/;
}
location /data/ {
    fastcgi_pass  unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_param SCRIPT_FILENAME /scripts/auth.php;
    fastcgi_param PHP_AUTH_USER $remote_user;
    fastcgi_param PHP_AUTH_PW $http_authorization;
    include fastcgi_params;
}
ボディを除いてほとんど同じPHPスクリプト:
// Get requested file name
$path = $_SERVER["REQUEST_URI"];
error_log("serving: " . $_SERVER['REMOTE_ADDR'] . ', user: ' . $_SERVER['PHP_AUTH_USER'] . ', path: ' . $path);
header("Content-Type: ", true);
header("X-Accel-Redirect: /protected" . $path);
              つまり、NGINXはLDAPをサポートしています。使用可能なアドオンモジュールは2つあります。NGINXには1つ、githubには別のモジュールが1つあります。NGINXソリューションは一見かなり複雑に見えたので、nginx-auth-ldapと呼ばれる後者の選択肢を選びました。私の経験に関するインストールノートを次のスレッドに投稿しました。
http://forum.nginx.org/read.php?2,18552で誰かがあなたの質問に答えたようです