2012年11月20日火曜日

apache2の設定


まず、httpd.confのhttpd-ssl.confのinludeを有効にします。

# diff -U0 httpd.conf.org httpd.conf
--- httpd.conf.org
+++ httpd.conf
@@ -477 +476 @@
-#Include /private/etc/apache2/extra/httpd-ssl.conf
+Include /private/etc/apache2/extra/httpd-ssl.conf

次にincludeしたhttpd-ssl.confの編集。

diff -U0 extra/httpd-ssl.conf.org extra/httpd-ssl.conf
--- extra/httpd-ssl.conf.org
+++ extra/httpd-ssl.conf

サーバーのhttps用のDocumentRootの設定、サーバー名等の設定
@@ -77,3 +77,3 @@
-DocumentRoot "/Library/WebServer/Documents"
-ServerName www.example.com:443
-ServerAdmin you@example.com
+DocumentRoot "/Library/WebServer/SecureDocuments"
+ServerName hogehoge.com:443
+ServerAdmin hoge@hogehoge.com

CA認証ファイルの指定
@@ -128,0 +129,4 @@
+#SSLCACertificatePath "/private/etc/apache2"
+SSLCACertificateFile "/private/etc/apache2/cacert.pem"

Client認証の要求設定
@@ -144,2 +148,2 @@
-#SSLVerifyClient require
-#SSLVerifyDepth  10
+SSLVerifyClient require
+SSLVerifyDepth  1

SecureDocumentのディレクトリ設定
@@ -195,0 +200,24 @@
+<Directory "/Library/WebServer/SecureDocuments">
+    Order allow,deny
+    Allow from all
+    SSLRequireSSL
+    SSLVerifyClient require
+</Directory>

将来のために各制御サーバー毎にdirectoryを切っておきます。
+<Directory "/Library/WebServer/SecureDocuments/control1">
+    AuthUserFile /private/etc/apache2/htpasswd/control1
+    AuthName "Please Your ID Passwd"
+    AuthType Basic
+    require valid-user
+    SSLRequireSSL
+    SSLVerifyClient require
+    SSLOptions +StdEnvVars +FakeBasicAuth
+</Directory>
+
+<Directory "/Library/WebServer/SecureDocuments/control2">
+    AuthUserFile /private/etc/apache2/htpasswd/control2
+    AuthName "Please Your ID Passwd"
+    AuthType Basic
+    require valid-user
+    SSLOptions +StdEnvVars +FakeBasicAuth
+</Directory>

各制御サーバーごとにパスワードファイルを作成します。
クライアント証明書のbackupのディレクトリへ行き

# openssl x509 -noout -subject -in newcert.pem

を実行するとsubjectが出力されます。
このsubject=を除いた部分をアカウントとしてhtpasswdを実行します。
control1用のアカウント1つめtest1

# htpasswd -c /private/etc/apache2/htpasswd/contro1 "/C=JP/ST….."

-cをつけるとパスワードファイルを新規に作成します。
2つ目のアカウントtest2

# htpasswd /private/etc/apache2/htpasswd/contro1 "/C=JP/ST….."

これを制御サーバーごとに繰り返します。

cgiの実行に関してはSSL関連の環境変数を実行時に確認してセキュリティを確保します。
これに関しては別途。

0 件のコメント:

コメントを投稿