nginxを使用したLDAPによるユーザー認証

nginxを使用したLDAPによるユーザー認証

私はapache2でLDAPを介してユーザーを認証する方法を知っています。

# put the following in the VirtualHost

<VirtualHost *:443>
    ServerAdmin [email protected] 
    DocumentRoot /var/www
    <Directory />
    AuthType Basic
    AuthName "Please provide USERNAME AND PASSWORD"
    AuthBasicProvider ldap
    Order allow,deny
    Allow from all
    AuthLDAPURL "ldaps://ehh.foo.com/ou=ehh,o=foo.com?mail"
    Require valid-user
    Require ldap-attribute [email protected]

尋ねる:しかし、私たちはnginxを使うべきです。 LDAP経由で認証するようにnginxをどのように設定しますか?

Ubuntu 12.04.5の使用

ベストアンサー1

これを行うには、ダウンロード/複製、コンパイル、インストールが必要です。nginx-認証-ldap

zipファイルをダウンロードできます。

wget https://github.com/kvspb/nginx-auth-ldap/archive/master.zip
unzip master.zip

それからcdあなたにnginxソースフォルダを選択し、次の操作を行います。

./configure --add-module=~-/nginx-auth-ldap-master
sudo make install

後で以下を設定できますnginx

http {
  ldap_server test1 {
    url ldap://192.168.0.1:3268/DC=test,DC=local?sAMAccountName?sub?(objectClass=person);
    binddn "TEST\\LDAPUSER";
    binddn_passwd LDAPPASSWORD;
    group_attribute uniquemember;
    group_attribute_is_dn on;
    require valid_user;
  }

  ldap_server test2 {
    url ldap://192.168.0.2:3268/DC=test,DC=local?sAMAccountName?sub?(objectClass=person);
    binddn "TEST\\LDAPUSER";
    binddn_passwd LDAPPASSWORD;
    group_attribute uniquemember;
    group_attribute_is_dn on;
    require valid_user;
  }
}

server {
    listen       8000;
    server_name  localhost;

    auth_ldap "Forbidden";
    auth_ldap_servers test1;
    auth_ldap_servers test2;

    location / {
        root   html;
        index  index.html index.htm;
    }

}

モジュール文書に示されているように。

おすすめ記事