NginxでLDAP認証
からの続き。
CentOS6にNginxを入れてLDAP認証させてみたときのメモ。
Nginx公式のrpmはldap対応していない(lddするとわかる。こちらを参照)。なのでまずこいつを削除する。
# yum list nginx Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.grandcloud.cn * extras: mirrors.yun-idc.com * updates: mirrors.163.com Installed Packages nginx.x86_64 1.4.4-1.el6.ngx @nginx # yum remove nginx Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Remove Process Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 0:1.4.4-1.el6.ngx will be erased --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Removing: nginx x86_64 1.4.4-1.el6.ngx @nginx 770 k Transaction Summary ================================================================================ Remove 1 Package(s) Installed size: 770 k Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Erasing : nginx-1.4.4-1.el6.ngx.x86_64 1/1 Verifying : nginx-1.4.4-1.el6.ngx.x86_64 1/1 Removed: nginx.x86_64 0:1.4.4-1.el6.ngx Complete! #
SRPMをインストール
http://dl.fedoraproject.org/pub/epel/6/SRPMS/repoview/nginx.htmlからSRPMをダウンロード。バージョンがちょっと古めなので、公式から現時点の安定板1.4.4の.tar.gzを持ってきてconfigure/makeするのもいいかもしれない。
$ wget http://dl.fedoraproject.org/pub/epel/6/SRPMS/nginx-1.0.15-5.el6.src.rpm --2013-12-23 15:09:12-- http://dl.fedoraproject.org/pub/epel/6/SRPMS/nginx-1.0.15-5.el6.src.rpm dl.fedoraproject.org をDNSに問いあわせています... 209.132.181.27, 209.132.181.23, 209.132.181.24, ... dl.fedoraproject.org|209.132.181.27|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 714233 (697K) [application/x-rpm] `nginx-1.0.15-5.el6.src.rpm' に保存中 100%[======================================>] 714,233 588K/s 時間 1.2s 2013-12-23 15:09:19 (588 KB/s) - `nginx-1.0.15-5.el6.src.rpm' へ保存完了 [714233/714233] $ cat .rpmmacros %_topdir /home/kohchi/rpmbuild $ rpm -ivh nginx-1.0.15-5.el6.src.rpm 警告: nginx-1.0.15-5.el6.src.rpm: ヘッダ V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY 1:nginx 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します ########################################### [100%] 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します 警告: ユーザ mockbuild は存在しません - root を使用します 警告: グループ mockbuild は存在しません - root を使用します $
.rpmmacrosで~/rpmbuild配下にできるように設定しているので、この場合はrpmbuild/SPECS配下にnginx.specが作成されているはず。
SPECファイルを修正してビルド
SPECファイルでnginx-auth-ldapを取得し、configureのオプションを追加(--add-module)する。nginx-auth-ldapは以下サイトにある。
つまり取得はgitで。
最初に必要なものをインストールしておく。今回はGeoIP-devel,gd-devel,pcre-develが必要だった。とくにGeoIP-develはデフォルトのリポジトリでは取得できないので、nginxと同様にepelからダウンロードした。
$ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/GeoIP-1.4.8-1.el6.x86_64.rpm --2013-12-23 15:40:12-- http://dl.fedoraproject.org/pub/epel/6/x86_64/GeoIP-1.4.8-1.el6.x86_64.rpm dl.fedoraproject.org をDNSに問いあわせています... 209.132.181.27, 209.132.181.23, 209.132.181.24, ... dl.fedoraproject.org|209.132.181.27|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 634944 (620K) [application/x-rpm] `GeoIP-1.4.8-1.el6.x86_64.rpm' に保存中 100%[======================================>] 634,944 611K/s 時間 1.0s 2013-12-23 15:40:19 (611 KB/s) - `GeoIP-1.4.8-1.el6.x86_64.rpm' へ保存完了 [634944/634944] $ wget http://dl.fedoraproject.org/pub/epel/6/x86_64/GeoIP-devel-1.4.8-1.el6.x86_64.rpm --2013-12-23 15:33:35-- http://dl.fedoraproject.org/pub/epel/6/x86_64/GeoIP-devel-1.4.8-1.el6.x86_64.rpm dl.fedoraproject.org をDNSに問いあわせています... 209.132.181.23, 209.132.181.24, 209.132.181.25, ... dl.fedoraproject.org|209.132.181.23|:80 に接続しています... 接続しました。 HTTP による接続要求を送信しました、応答を待っています... 200 OK 長さ: 10980 (11K) [application/x-rpm] `GeoIP-devel-1.4.8-1.el6.x86_64.rpm' に保存中 100%[======================================>] 10,980 --.-K/s 時間 0.005s 2013-12-23 15:33:41 (2.29 MB/s) - `GeoIP-devel-1.4.8-1.el6.x86_64.rpm' へ保存完了 [10980/10980] # su Password: # rpm -ivh GeoIP-1.4.8-1.el6.x86_64.rpm 警告: GeoIP-1.4.8-1.el6.x86_64.rpm: ヘッダ V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY 準備中... ########################################### [100%] 1:GeoIP ########################################### [100%] [root@localhost nginx]# rpm -ivh GeoIP-devel-1.4.8-1.el6.x86_64.rpm 警告: GeoIP-devel-1.4.8-1.el6.x86_64.rpm: ヘッダ V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY 準備中... ########################################### [100%] 1:GeoIP-devel ########################################### [100%] # # yum install gd-devel Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.grandcloud.cn * extras: mirrors.yun-idc.com * updates: mirrors.163.com Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package gd-devel.x86_64 0:2.0.35-11.el6 will be installed --> Processing Dependency: gd = 2.0.35-11.el6 for package: gd-devel-2.0.35-11.el6.x86_64 --> Processing Dependency: libXpm-devel for package: gd-devel-2.0.35-11.el6.x86_64 --> Processing Dependency: libgd.so.2()(64bit) for package: gd-devel-2.0.35-11.el6.x86_64 --> Running transaction check ---> Package gd.x86_64 0:2.0.35-11.el6 will be installed ---> Package libXpm-devel.x86_64 0:3.5.10-2.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: gd-devel x86_64 2.0.35-11.el6 base 78 k Installing for dependencies: gd x86_64 2.0.35-11.el6 base 142 k libXpm-devel x86_64 3.5.10-2.el6 base 33 k Transaction Summary ================================================================================ Install 3 Package(s) Total download size: 253 k Installed size: 890 k Is this ok [y/N]: y Downloading Packages: (1/3): gd-2.0.35-11.el6.x86_64.rpm | 142 kB 00:00 (2/3): gd-devel-2.0.35-11.el6.x86_64.rpm | 78 kB 00:00 (3/3): libXpm-devel-3.5.10-2.el6.x86_64.rpm | 33 kB 00:01 -------------------------------------------------------------------------------- Total 30 kB/s | 253 kB 00:08 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Warning: RPMDB altered outside of yum. Installing : gd-2.0.35-11.el6.x86_64 1/3 Installing : libXpm-devel-3.5.10-2.el6.x86_64 2/3 Installing : gd-devel-2.0.35-11.el6.x86_64 3/3 Verifying : gd-devel-2.0.35-11.el6.x86_64 1/3 Verifying : libXpm-devel-3.5.10-2.el6.x86_64 2/3 Verifying : gd-2.0.35-11.el6.x86_64 3/3 Installed: gd-devel.x86_64 0:2.0.35-11.el6 Dependency Installed: gd.x86_64 0:2.0.35-11.el6 libXpm-devel.x86_64 0:3.5.10-2.el6 Complete! # # yum install pcre-devel Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.grandcloud.cn * extras: mirrors.yun-idc.com * updates: mirrors.163.com Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package pcre-devel.x86_64 0:7.8-6.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: pcre-devel x86_64 7.8-6.el6 base 318 k Transaction Summary ================================================================================ Install 1 Package(s) Total download size: 318 k Installed size: 954 k Is this ok [y/N]: y Downloading Packages: pcre-devel-7.8-6.el6.x86_64.rpm | 318 kB 00:07 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : pcre-devel-7.8-6.el6.x86_64 1/1 Verifying : pcre-devel-7.8-6.el6.x86_64 1/1 Installed: pcre-devel.x86_64 0:7.8-6.el6 Complete! #
specファイルの修正してRPMを作成。
$ cd rpmbuild/SPECS $ cp -ip nginx.spec nginx.spec.org $ vi nginx.spec 以下のように変更する。 $ diff -u nginx.spec.org nginx.spec --- nginx.spec.org 2013-04-27 05:36:58.000000000 +0900 +++ nginx.spec 2013-12-23 15:24:14.630698525 +0900 @@ -9,7 +9,7 @@ Name: nginx Version: 1.0.15 -Release: 5%{?dist} +Release: authldap%{?dist} Summary: A high performance web server and reverse proxy server Group: System Environment/Daemons @@ -67,6 +67,8 @@ %build +# get nginx-auth-ldap +git clone https://github.com/kvspb/nginx-auth-ldap.git # nginx does not utilize a standard configure script. It has its own # and the standard configure options cause the nginx configure script # to error out. This is is also the reason for the DESTDIR environment @@ -87,6 +89,7 @@ --lock-path=%{_localstatedir}/lock/subsys/nginx \ --user=%{nginx_user} \ --group=%{nginx_group} \ + --add-module=./nginx-auth-ldap/ \ --with-file-aio \ --with-ipv6 \ --with-http_ssl_module \ $ rpmbuild -bb nginx.spec .... Processing files: nginx-debuginfo-1.0.15-authldap.el6.x86_64 伸張ファイルの検査中: /usr/lib/rpm/check-files /home/kohchi/rpmbuild/BUILDROOT/nginx-1.0.15-authldap.el6.x86_64 書き込み完了: /home/kohchi/rpmbuild/RPMS/x86_64/nginx-1.0.15-authldap.el6.x86_64.rpm 書き込み完了: /home/kohchi/rpmbuild/RPMS/x86_64/nginx-debuginfo-1.0.15-authldap.el6.x86_64.rpm 実行中(%clean): /bin/sh -e /var/tmp/rpm-tmp.QM16Bc + umask 022 + cd /home/kohchi/rpmbuild/BUILD + cd nginx-1.0.15 + /bin/rm -rf /home/kohchi/rpmbuild/BUILDROOT/nginx-1.0.15-authldap.el6.x86_64 + exit 0 $ ls -alF ../RPMS/x86_64/nginx-* -rw-rw-r-- 1 kohchi kohchi 414136 12月 23 15:45 2013 ../RPMS/x86_64/nginx-1.0.15-authldap.el6.x86_64.rpm -rw-rw-r-- 1 kohchi kohchi 1621256 12月 23 15:45 2013 ../RPMS/x86_64/nginx-debuginfo-1.0.15-authldap.el6.x86_64.rpm $
おぉ、できてる。なのでインストールしてみる。
$ su Password: # cd ../RPMS/x86_64/ # yum install nginx-1.0.15-authldap.el6.x86_64.rpm Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.grandcloud.cn * extras: mirrors.yun-idc.com * updates: mirrors.163.com Setting up Install Process Examining nginx-1.0.15-authldap.el6.x86_64.rpm: nginx-1.0.15-authldap.el6.x86_64 Marking nginx-1.0.15-authldap.el6.x86_64.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package nginx.x86_64 0:1.0.15-authldap.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: nginx x86_64 1.0.15-authldap.el6 /nginx-1.0.15-authldap.el6.x86_64 1.1 M Transaction Summary ================================================================================ Install 1 Package(s) Total size: 1.1 M Installed size: 1.1 M Is this ok [y/N]: y Downloading Packages: Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : nginx-1.0.15-authldap.el6.x86_64 1/1 Verifying : nginx-1.0.15-authldap.el6.x86_64 1/1 Installed: nginx.x86_64 0:1.0.15-authldap.el6 Complete! # rpm -ql nginx-1.0.15 /etc/logrotate.d/nginx /etc/nginx /etc/nginx/conf.d /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/ssl.conf /etc/nginx/conf.d/virtual.conf /etc/nginx/fastcgi.conf /etc/nginx/fastcgi.conf.default /etc/nginx/fastcgi_params /etc/nginx/fastcgi_params.default /etc/nginx/koi-utf /etc/nginx/koi-win /etc/nginx/mime.types /etc/nginx/mime.types.default /etc/nginx/nginx.conf /etc/nginx/nginx.conf.default /etc/nginx/scgi_params /etc/nginx/scgi_params.default /etc/nginx/uwsgi_params /etc/nginx/uwsgi_params.default /etc/nginx/win-utf /etc/rc.d/init.d/nginx /etc/sysconfig/nginx /usr/lib64/perl5/vendor_perl/auto/nginx /usr/lib64/perl5/vendor_perl/auto/nginx/nginx.so /usr/lib64/perl5/vendor_perl/nginx.pm /usr/sbin/nginx /usr/share/doc/nginx-1.0.15 /usr/share/doc/nginx-1.0.15/CHANGES /usr/share/doc/nginx-1.0.15/LICENSE /usr/share/doc/nginx-1.0.15/README /usr/share/man/man3/nginx.3pm.gz /usr/share/man/man8/nginx.8.gz /usr/share/nginx /usr/share/nginx/html /usr/share/nginx/html/404.html /usr/share/nginx/html/50x.html /usr/share/nginx/html/index.html /usr/share/nginx/html/nginx-logo.png /usr/share/nginx/html/poweredby.png /var/lib/nginx /var/lib/nginx/tmp /var/log/nginx # ldd /usr/sbin/nginx linux-vdso.so.1 => (0x00007fff2cdff000) libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003033000000) libcrypt.so.1 => /lib64/libcrypt.so.1 (0x000000303c800000) libldap-2.4.so.2 => /lib64/libldap-2.4.so.2 (0x0000003045c00000) libpcre.so.0 => /lib64/libpcre.so.0 (0x0000003044c00000) libssl.so.10 => /usr/lib64/libssl.so.10 (0x0000003042400000) libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x000000303f000000) libdl.so.2 => /lib64/libdl.so.2 (0x0000003032c00000) libz.so.1 => /lib64/libz.so.1 (0x0000003033800000) libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x000000303d400000) libxslt.so.1 => /usr/lib64/libxslt.so.1 (0x0000003045400000) libexslt.so.0 => /usr/lib64/libexslt.so.0 (0x0000003043000000) libgd.so.2 => /usr/lib64/libgd.so.2 (0x00007fa84ec7e000) libGeoIP.so.1 => /usr/lib64/libGeoIP.so.1 (0x00000032b7e00000) libperl.so => /usr/lib64/perl5/CORE/libperl.so (0x0000003033c00000) libresolv.so.2 => /lib64/libresolv.so.2 (0x0000003034400000) libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003043400000) libm.so.6 => /lib64/libm.so.6 (0x0000003032800000) libutil.so.1 => /lib64/libutil.so.1 (0x0000003042c00000) libc.so.6 => /lib64/libc.so.6 (0x0000003032400000) liblber-2.4.so.2 => /lib64/liblber-2.4.so.2 (0x0000003044000000) /lib64/ld-linux-x86-64.so.2 (0x0000003032000000) libfreebl3.so => /lib64/libfreebl3.so (0x000000303cc00000) libssl3.so => /usr/lib64/libssl3.so (0x0000003042800000) libsmime3.so => /usr/lib64/libsmime3.so (0x0000003042000000) libnss3.so => /usr/lib64/libnss3.so (0x0000003041000000) libnssutil3.so => /usr/lib64/libnssutil3.so (0x0000003041800000) libplds4.so => /lib64/libplds4.so (0x0000003041c00000) libplc4.so => /lib64/libplc4.so (0x0000003041400000) libnspr4.so => /lib64/libnspr4.so (0x0000003040c00000) libsasl2.so.2 => /usr/lib64/libsasl2.so.2 (0x000000303fc00000) libgssapi_krb5.so.2 => /lib64/libgssapi_krb5.so.2 (0x0000003040800000) libkrb5.so.3 => /lib64/libkrb5.so.3 (0x000000303f400000) libcom_err.so.2 => /lib64/libcom_err.so.2 (0x000000303dc00000) libk5crypto.so.3 => /lib64/libk5crypto.so.3 (0x000000303e800000) libgcrypt.so.11 => /lib64/libgcrypt.so.11 (0x0000003045000000) libgpg-error.so.0 => /lib64/libgpg-error.so.0 (0x0000003043800000) libXpm.so.4 => /usr/lib64/libXpm.so.4 (0x000000303c400000) libX11.so.6 => /usr/lib64/libX11.so.6 (0x0000003035400000) libjpeg.so.62 => /usr/lib64/libjpeg.so.62 (0x00007fa84ea25000) libfontconfig.so.1 => /usr/lib64/libfontconfig.so.1 (0x0000003037800000) libfreetype.so.6 => /usr/lib64/libfreetype.so.6 (0x0000003037000000) libpng12.so.0 => /usr/lib64/libpng12.so.0 (0x0000003036400000) libkrb5support.so.0 => /lib64/libkrb5support.so.0 (0x000000303ec00000) libkeyutils.so.1 => /lib64/libkeyutils.so.1 (0x000000303f800000) libxcb.so.1 => /usr/lib64/libxcb.so.1 (0x0000003035800000) libexpat.so.1 => /lib64/libexpat.so.1 (0x0000003036800000) libselinux.so.1 => /lib64/libselinux.so.1 (0x0000003034000000) libXau.so.6 => /usr/lib64/libXau.so.6 (0x0000003035c00000) #
libldap-2.4.so.2にリンクされていることを確認。
動作確認
とりあえず、httpをお話できるか確認。
# /sbin/chkconfig --list nginx nginx 0:off 1:off 2:off 3:off 4:off 5:off 6:off # service nginx start nginx を起動中: [ OK ] # ps -ef | grep nginx root 12180 1 0 15:56 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf nginx 12182 12180 0 15:56 ? 00:00:00 nginx: worker process root 12185 5650 0 15:56 pts/1 00:00:00 grep nginx # telnet localhost 80 Trying ::1... telnet: connect to address ::1: Connection refused Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. GET / HTTP/1.0 HTTP/1.1 200 OK Server: nginx/1.0.15 Date: Mon, 23 Dec 2013 06:57:17 GMT Content-Type: text/html Content-Length: 3698 Last-Modified: Fri, 26 Apr 2013 20:36:51 GMT Connection: close Accept-Ranges: bytes <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Test Page for the Nginx HTTP Server on EPEL</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <style type="text/css"> /*<![CDATA[*/ body { background-color: #fff; color: #000; font-size: 0.9em; font-family: sans-serif,helvetica; margin: 0; padding: 0; } :link { color: #c00; } :visited { color: #c00; } a:hover { color: #f50; } h1 { text-align: center; margin: 0; padding: 0.6em 2em 0.4em; background-color: #294172; color: #fff; font-weight: normal; font-size: 1.75em; border-bottom: 2px solid #000; } h1 strong { font-weight: bold; font-size: 1.5em; } h2 { text-align: center; background-color: #3C6EB4; font-size: 1.1em; font-weight: bold; color: #fff; margin: 0; padding: 0.5em; border-bottom: 2px solid #294172; } hr { display: none; } .content { padding: 1em 5em; } .alert { border: 2px solid #000; } img { border: 2px solid #fff; padding: 2px; margin: 2px; } a:hover img { border: 2px solid #294172; } .logos { margin: 1em; text-align: center; } /*]]>*/ </style> </head> <body> <h1>Welcome to <strong>nginx</strong> on EPEL!</h1> <div class="content"> <p>This page is used to test the proper operation of the <strong>nginx</strong> HTTP server after it has been installed. If you can read this page, it means that the web server installed at this site is working properly.</p> <div class="alert"> <h2>Website Administrator</h2> <div class="content"> <p>This is the default <tt>index.html</tt> page that is distributed with <strong>nginx</strong> on EPEL. It is located in <tt>/usr/share/nginx/html</tt>.</p> <p>You should now put your content in a location of your choice and edit the <tt>root</tt> configuration directive in the <strong>nginx</strong> configuration file <tt>/etc/nginx/nginx.conf</tt>.</p> </div> </div> <div class="logos"> <a href="http://nginx.net/"><img src="nginx-logo.png" alt="[ Powered by nginx ]" width="121" height="32" /></a> <a href="http://fedoraproject.org/"><img src="poweredby.png" alt="[ Powered by Fedora EPEL ]" width="88" height="31" /></a> </div> </div> </body> </html> Connection closed by foreign host. #
EPEL版のデフォルトページはWelcome to nginx on EPEL!となっているみたい。
nginxでのLDAP設定
以前設定したLDAPをそのまま使用する。
- データディレクトリ権限としてManagerを与えていたのでそれをbind用アカウントとして設定。
- 以前設定したposixAccountをそのまま認証として設定。
- デフォルトの/usr/share/nginx/html配下にldapディレクトリを作成し、そこは登録ユーザの認証が必要になるように設定する。
なお、これらldapコマンドとしては以下のとおり。
$ ldapsearch -x -LLL -b 'dc=miyagino,dc=net' -D 'cn=Manager,dc=miyagino,dc=net' -W Enter LDAP Password: .... $ ldapsearch -x -s sub -b 'ou=Users,dc=miyagino,dc=net' '(objectClass=posixAccount)' uid ....
ldap_serverをグローバル設定部分に設定し、認証させたいロケーション部分にグローバル設定した名前を指定する。
# cd /etc/nginx # cp -ip nginx.conf nginx.conf.org # vi nginx.conf http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; # for LDAP ldap_server test0 { url ldap://localhost/ou=Users,dc=miyagino,dc=net?uid?sub?(objectClass=posixAccount); binddn cn=Manager,dc=miyagino,dc=net; binddn_passwd 'パスワード文字列。残念ながら生文字列'; require valid_user; } .... # cd conf.d # cp -ip default.conf default.conf.org # vi default.conf server { .... location /ldap/ { # for LDAP auth_ldap 'LDAP Authentication'; auth_ldap_servers test0; } } # service nginx reload nginx を再読み込み中: [ OK ] #
これで http://localhost/ にはパスワードなしで、 http://localhost/ldap/ にはパスワードありでアクセスできることを確認する。
その他
LDAPリポジトリのメンテナンスツールは Apache Directory Studio が便利です。ldapaddコマンドとか知らなくても大丈夫。
なんだって。知らなかった。
で、これら全部の元記事は以下。