# portinstall www/wget4web
で一発。
あらかじめApacheが入っていないとApacheのインストールから始めようとするので要注意。 あとでApache2.2を入れるつもりだったのがApache1.3xを入れようとするのでちょっと焦った。
# portinstall www/wget4web
で一発。
あらかじめApacheが入っていないとApacheのインストールから始めようとするので要注意。 あとでApache2.2を入れるつもりだったのがApache1.3xを入れようとするのでちょっと焦った。
今日は適当にメモっただけ。後日清書するかも。
/usr/ports/www/apache22
/usr/local/etc/pkgtools.conf
MAKE_ARGS = {
‘www/apache22′ => [
‘WITHOUT_DAV_MODULES=yes’,
‘WITHOUT_PROXY_MODULES=yes’,
‘WITHOUT_IPV6=yes’,
],
}
# portinstall www/apache22
# diff /usr/local/etc/apache22/httpd.conf httpd.conf.org
40c40
< Listen www.xxx.yyy.zzz:80
—
> Listen 80
132c132
< ServerAdmin www@ほげほげ
—
> ServerAdmin you@example.com
453,468d452
< < NameVirtualHost *:80
<
<
< ServerAdmin webmaster@ほげほげ
< DocumentRoot /usr/home/www/404
< ServerName 404.ほげほげ
<
< Options Indexes FollowSymLinks
< AllowOverride None
< Order allow,deny
< Allow from all
<
< ErrorLog /var/log/404.ほげほげ-error_log
< CustomLog /var/log/404.ほげほげ-access_log common
<
こうしておけば /usr/local/etc/apache22/Includesで設定していないホストへのアクセスを全部ここに集中できる。
# /usr/bin/openssl genrsa -out /usr/local/etc/apache22/server.key 1024
# /usr/bin/openssl req -new -days 365 -key /usr/local/etc/apache22/server.key -out /usr/local/etc/apache22/server.csr -out /usr/local/etc/apache22/server.csr
なんちゃって自己証明
# /usr/bin/openssl x509 -in /usr/local/etc/apache22/server.csr -out /usr/local/etc/apache22/server.crt -req -signkey /usr/local/etc/apache22/server.key -days 365
# chmod 600 server.*
を忘れずに。
/usr/local/etc/apache22/extra/httpd-ssl.confのDocumentRoot, ServerName, ServerAdminをを適当に書き換えて/usr/local/etc/apache22/Includes/httpd-ssl.confに置く。
あと、必要に応じて /usr/local/etc/apache22/IncludesにVirtual Hostのファイルを作って置けばOK。こんな感じ
# Virtual Hosts
#
ServerAdmin webmaster@へろへろ
DocumentRoot /usr/home/www/http
ServerName www.へろへろ
ServerAlias へろへろ
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
ErrorLog /var/log/www.へろへろ-error_log
CustomLog /var/log/www.へろへろ-access_log common
Apcheの再起動は /usr/local/etc/rc.d/apache22 restart
# /usr/local/etc/rc.d/apache22
Usage: /usr/local/etc/rc.d/apache22 [fast|force|one](start|stop|restart|rcvar|re
load|graceful|gracefulstop|configtest|status|poll)
/usr/local/etc/apache22/Includes/no-accf.confはそのままそっと置いておく。
サーバーをインタネットに公開するとsshの扉を叩く人がかなりいます。それも手持ちの鍵(idとパスワード)を順番に片っ端から試していく奴が結構沢山。
そこで、Maxloginsを使ってみる。このツールはsyslogでsshアクセス失敗回数を監視し、一定の基準を超えたアクセス禁止のIPアドレスリストを吐き出す。そのリストをhosts.allowに取り込んでsshのアクセスを禁止する仕組み。
ツールの実体はここにある。 テキストファイルだけど、”maxlogins.pl”とかの名前で/usr/local/bin に保存すし、次のようにしてsyslogから実行できるようにしておく。
# chown root:wheel /usr/local/bin/maxlogins.pl
# chmod 750 /usr/local/bin/maxlogins.pl
/etc/syslog.conf に以下を挿入する。
auth.info;authpriv.info /var/log/auth.log # ←この行の次に
auth.info;authpriv.info |exec /usr/local/bin/maxlogins.pl # ←この行を追加
このmaxlogins.pl にはオプションを追加指定できる。
-e: アクセス禁止の解除時間の指定。デフォルトは12時間。
-e=1d, -e=24h, -e=1440m, -e=86400s という感じで指定する。この場合いづれも1日の意味。
-a: IPアドレスがブロックされるまでの最大試行回数。 デフォルトは3回。
-a=5 という風に指定する。
-l: ログレベルの指定。 ログはデフォルトで /var/log/auth.logに記録される。
-l=1: informational (e.g., new blocks)
-l=2: above, plus IP expirations
-l=9: verbose logging
/etc/hosts.allow をいじって「アクセス禁止のIPアドレスリスト」を読み込むようにする。
#ALL : ALL : allow
sshd : 127.0.0.1 : allow
sshd : /var/log/maxlogins : deny
sshd : ALL : allow
ちなみに、これをやったらpopとかimapとかの設定も忘れずに。
ftpd : localhost : allow
ftpd : ALL : allow
ipop3d : ALL : allow
imapd : localhost : allow
imapd : ALL : deny
最後に、 syslog を再起動。
# kill -HUP (syslogのpid)
ブロックされたIPアドレスは /var/log/maxlogins に記録される。
参考リンク: 1
「送信元のIPアドレスによる制限」を行う。
/usr/local/etc/postfix/main.cf に下記を追加
############### # sender restriction # smtpd_client_restrictions = permit_mynetworks check_client_access hash:/usr/local/etc/postfix/reject_client
/usr/local/etc/postfix/reject_client を下記のように作成。
IPアドレス1(tab)REJECT IPアドレス2(tab)REJECT IPアドレス3(tab)REJECT
DBファイル作成してpostfixを再起動
# postmap /usr/local/etc/postfix/reject_client # postfix reload
#################### # SMTP AUTH w/SALS2 # smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = $myhostname broken_sasl_auth_clients = yes smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
/usr/local/lib/sasl2/smtpd.confを作る。
# cat /usr/local/lib/sasl2/smtpd.conf pwcheck_method: auxprop auxprop_plugin: sasldb mech_list: cram-md5 digest-md5 plain login
/etc/sasldb2を用意しておく。
# touch /etc/sasldb2 # chown postfix:postfix /etc/sasldb2
smtp-authのユーザーを作る。
# saslpasswd2 -c -u `postconf -h myhostname` username
パスワードを二回訊いてくるので入力する。
ユーザーのパスワードの変更
# saslpasswd2 -u `postconf -h myhostname` username
同じくパスワードを二回訊いてくるので入力する。
ユーザーの削除
# saslpasswd2 -u `postconf -h myhostname` -d username
ユーザーの確認
# sasldblistusers2