nginxでLDAP認証
nginxで特定location以下をLDAP認証するようにしてみました。
ldap認証モジュールをいれる
nginx-auth-ldapモジュールをいれます。ブツは https://github.com/kvspb/nginx-auth-ldap にあるのでcloneするなり、ダウンロードするなり。
適当に展開したあとに、nginx側でconfigure。
$ ./configure --add-module=../nginx-auth-ldap \ --add-module=../nginx_ajp_module \ --with-http_ssl_module \ --with-http_realip_module \ --with-http_stub_status_module
その後make,make install
ldap認証サーバ設定
http{}以下へldap_serverの設定をいれる。
ldap_server ad_1 { url "ldap://xxx.xxx.xxx.xxx:yyyy/ou=user,ou=xxx?uid?sub?(objectClass=person)" ; binddn "CN=Operator,Ou=Service,DC=hoge,DC=com" binddn_passwd hogehogehoge ; require 'valid_user' ; }
認証情報(binddn_passwd)が含まれているので、別ファイルにしてパーミションを厳しくしたうえで、includeするのがいいかもしれません。