T インストール作業〜SSL+ユーザ認証〜


1.SSLの導入

# rpm -ihv mod_ssl-2.0.47-10.i386.rpm
警告: mod_ssl-2.0.47-10.i386.rpm: V3 DSA signature: NOKEY, key ID ****
Preparing... ########################################### [100%]
1:mod_ssl ########################################### [100%]

2.証明書の作成

デフォルト鍵の削除

# rm /etc/httpd/conf/ssl.key/server.key
rm: remove 通常ファイル `/etc/httpd/conf/ssl.key/server.key'? y
# rm /etc/httpd/conf/ssl.crt/server.crt
rm: remove 通常ファイル `/etc/httpd/conf/ssl.crt/server.crt'? y

鍵を作成

# cat /var/log/*.log > random.dat
# /usr/bin/openssl genrsa -rand random.bat -des3 1024 > /etc/httpd/conf/ssl.key/server.key
0 semi-random bytes loaded
Generating RSA private key, 1024 bit long modulus
...++++++
..........++++++
e is 65537 (0x10001)
Enter pass phrase:(パスワード)
Verifying - Enter pass phrase:(パスワード)
# rm random.dat
rm: remove 通常ファイル `random.dat'? y
# /usr/bin/openssl req -new -key /etc/httpd/conf/ssl.key/server.key -x509 -days 365 -out /etc/httpd/conf/ssl.crt/server.crt
Enter pass phrase for /etc/httpd/conf/ssl.key/server.key:
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:JP
State or Province Name (full name) [Berkshire]:kokura
Locality Name (eg, city) [Newbury]:kita
Organization Name (eg, company) [My Company Ltd]:kkataru
Organizational Unit Name (eg, section) []:web team
Common Name (eg, your name or your server's hostname) []:kkataru.mine.nu
Email Address []:ataru@kkataru.mine.nu

3.ユーザ認証(ベーシック認証)

# cd /etc/httpd/conf

に移動する。

パスワードを作成するコマンドは、htpasswedです。

(初めて作成する場合)

# htpasswd -c .htpasswd ataru
New password:(パスワード)
Re-type new password:(パスワード)
Adding password for user ataru

# ls -la
-rw-r--r-- 1 root root 20 3月 7 00:18 .htpasswd

root権限で作成されているのでapacheユーザが読み取れるように変更する。

# chown apache:apache .htpasswd

-rw-r--r-- 1 apache apache 20 3月 7 00:18 .htpasswd

##ataru Access Control
<Directory "/home/ataru/web02">
Allow from 192.168.2.0/255.255.255.0
Deny from all
Order Deny,Allow
AuthType Basic
AuthName "This page is menber only"
AuthUserFile "conf/.htpasswd"
Require valid-user
</Directory>

# /etc/rc.d/init.d/httpd reload
httpdを再読み込み中: [ OK ]