apache + SSL

[ Nob's Home | FreeBSD ]

apacheをSSL対応にして、ついでに1.1.1にversion upしました。
これまでは /usr/local/www/server/以下にapache_1.1b4をisntallしていました。

FreeBSD 2.1Rにはdesをinstallしてあります。(cf. des.html)

を参考にさせていただきました。

また、いろいろとアドバイスをpgp mailing listの皆さんからいただきました。
ありがとうございました。

まずapacheを1.1.1にします。

を参照。 から apache_1.1.1.tar.gz をget
	$ tar zxvf  apache_1.1.1.tar.gz  
と展開しておく。

SSLeayについては http://www.psy.uq.oz.au/‾ftp/Crypto/を参照。

からSSLeay-0.6.4.tar.gzをget
	$ tar zxvf SSLeay-0.6.4.tar.gz
	$ cd SSLeay-0.6.4
	$ make						(gmakeであること)
	$ make rehash
	$ make test
	$ su
	# make install
	$ exit

ftp://ftp.ox.ac.uk/pub/crypto/SSL/からapache_1.1.1+1.3.ssl.tar.gzをget。

	$ cd apache_1.1.1
	$ tar zxvf ../apache_1.1.1+1.3.ssl.tar.gz
	$ patch < SSLpatch
	$ cd src
	$ vi Configuration
		SSL_BASE=/usr/local/ssl に
		SSL_LIB_DIR= $(SSL_BASE)/lib に
		AUX_CFLAGS= -DSCO5 をcomment out 
		AUX_LIBS=-lsocket -lmalloc -lprot をcomment out 
		BROKEN_BPRINTF_FLAGS=-K noinline をcomment out 

		# -m486 only if you are running on Intel 486/586
		#AUX_CFLAGS= -m486 ここの #をとる
		# BSDI doesn't need -lcrypt
		#AUX_LIBS= -lcrypt ここの #をとる
	$ vi Makefile.tmpl
		$(SSL_LIB_DIR)/apps/ssleay を $(SSL_BASE)/bin/ssleay に
		$(SSL_LIB_DIR)/apps/ssleay.conf を $(SSL_LIB_DIR)/ssleay.conf に
	$ ./Configure
	$ make
	$ make certificate

	/usr/local/ssl/bin/ssleay req  -config /usr/local/ssl/lib/ssleay.conf  -new -x509 -nodes 
	-out ../SSLconf/conf/httpsd.pem  -keyout ../SSLconf/conf/httpsd.pem;
	ln -sf ../SSLconf/conf/httpsd.pem ../SSLconf/conf/`/usr/local/ssl/bin/ssleay  x509 -noout -hash 
	< ../SSLconf/conf/httpsd.pem`.0
	Generating a 512 bit private key
	...+++++
	.+++++
	writing new private key to '../SSLconf/conf/httpsd.pem'
	-----
	You are about to be asked to enter information that will be incorperated
	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) [AU]:jp
	State or Province Name (full name) [Queensland]:Yamanashi
	Locality Name (eg, city) []:Makioka
	Organization Name (eg, company) [Mincom Pty Ltd]:Makioka Hospital
	Organizational Unit Name (eg, section) [MTR]:Internal Medicine
	Common Name (eg, YOUR name) []:MURATA Nobuhiro
	Email Address []:nob@makioka.y-min.or.jp
これで httpsdができました。
各種設定ファイルは/usr/local/etc/httpd に置くことにします。
	$ su
	# mkdir /usr/local/etc/httpd
	# cd apache_1.1.1
	# tar cf - . | (cd /usr/local/etc/httpd ; tar xvpf - )

/usr/local/www/home/private/へのアクセスを認証するよう設定します。
まず、通常のaccess controlの設定。
/usr/local/www/secretにpasswd fileを置きます。
htpasswdでnob という userを登録します。

	# mkdir /usr/local/www/secret
	# cd /usr/local/etc/httpd/support/
	# vi Makefile
		EXTRA_LIBS=-lcrypt にします
	# make htpasswd
	# ./htpasswd -c /usr/local/www/secret/passwd nob
	  Adding password for nob.
	  New password:
	  Re-type new password:

.htaccessを設定します

/usr/local/www/home/private/.htaccess の内容
	AuthType Basic
	AuthName Makioka Secure test
	AuthUserFile /usr/local/www/secret/passwd
	<LIMIT GET>
        require user nob
	</LIMIT>
これまで使用していた srm.confとaccess.confをcpしてSSLconf/conf/httpd.confを修正
	$ cp /usr/local/www/server/conf/srm.conf /usr/local/etc/httpd/conf/
	$ cp /usr/local/www/server/conf/access.conf /usr/local/etc/httpd/conf/
	$ vi /usr/local/etc/httpd/SSLconf/conf/httpd.conf
		ServerName makioka.y-min.or.jp
		HostnameLookups off
		User nobody
		Group nobody
		ServerAdmin nob@makioka.y-min.or.jp
			を追加
		Port 443
		#SSLDisable
		SSLCertificateFile /usr/local/etc/httpd/SSLconf/conf/httpsd.pem
			とする
		#SSLCACertificatePath
		#SSLCACertificateFile
			は commentに

# /usr/local/etc/httpd/src/httpsd -f /usr/local/etc/httpd/SSLconf/conf/httpd.conf で起動


[ Nob's Home | FreeBSD ]
nob@makioka.y-min.or.jp