34.ドメイン移行話の続き(2004/11/23)
34.1.Webサーバの設定
またまた、半年以上も更新ブッチしました。
ashiyu.netに移行して、8ヶ月ほど経とうとしているのに、今更ながらドメイン移行話の続きをば。
まずはapache。
ウチのサーバは、以下4つのドメインを処理せねばなりませぬ。
2年もの間2001番ポートで運用していたんで、2001番ポートも開けといて、うまい具合に捌いていく必要があります。
かといって難しいことはなく、PORT番号の振り分けもドメインの振り分けもVirtualHostを使えば出来そうです。
〜/etc/httpd/conf/httpd.conf〜
NameVirtualHost *
<VirtualHost *>
DocumentRoot /home/httpd/html/noip
ServerName www.ashiyu.no-ip.com
ServerAlias ashiyu.no-ip.com *.ashiyu.no-ip.com
User ashiyu
Group ashiyumember
</VirtualHost>
<VirtualHost *>
DocumentRoot /home/httpd/html
ServerName www.ashiyu.net
ServerAlias ashiyu.net *.ashiyu.net
User ashiyu
Group ashiyumember
</VirtualHost>
NameVirtualHost *:2001
<VirtualHost *:2001>
DocumentRoot /home/httpd/html/noip
ServerName www.ashiyu.no-ip.com
ServerAlias ashiyu.no-ip.com *.ashiyu.no-ip.com
User ashiyu
Group ashiyumember
</VirtualHost>
<VirtualHost *:2001>
DocumentRoot /home/httpd/html
ServerName www.ashiyu.net
ServerAlias ashiyu.net *.ashiyu.net
User ashiyu
Group ashiyumember
</VirtualHost>
|
あとは、ashiyu.no-ip.comへ来た人に対して、ashiyu.netへの移行を通知する必要があります。
いろいろ考えた結果、サイト全体を消去して、ErrorDocumentを用いるのが手っ取り早そうです。
というわけで、ashiyu.no-ip.com のページは、/home/httpd/html/noip に移動して、index.html以外は全部消去することに。
ちなみに、index.htmlには、引越しました的なページを置く。
/etc/httpd/conf/httpd.conf の設定はこんな感じ。
〜/etc/httpd/conf/httpd.conf〜
<Directory /home/httpd/html/noip>
ErrorDocument 404 /index.html
Options +ExecCGI +FollowSymLinks
</Directory>
|
Options の設定は関係ないです。(CGIとリンクの許可してるだけ)
これで、http://www.ashiyu.no-ip.com へのアクセスは、どこにアクセスしようともindex.htmlに転送されます。
あとは忘れずに、ServerAdminの変更も行い、apacheの再起動でOK。
34.2.メールサーバの設定
メールサーバも、ashiyu.netとashiyu.no-ip.comを捌ける必要があります。
とりあえず、メインはashiyu.netになるわけなので、既存の設定をすべてashiyu.netに変更します。
以前の設定はコメントアウト。
〜/etc/postfix/main.cf〜
myhostname = junkserver.ashiyu.net
#myhostname = junkserver.ashiyu.no-ip.com
mydomain = ashiyu.net
#mydomain = ashiyu.no-ip.com
|
これでashiyu.net宛のメールは使用可能になる。
で、ashiyu.no-ip.com宛だけど、Postfixで複数ドメインを扱う方法はvirtual_mapsを使うのが簡単そうです。
/etc/postfix/main.cf 内をvirtual_mapsで検索すると、既に virtual_maps = hash:/etc/postfix/virtual と設定されているはず。
というわけで、このまま/etc/postfix/virtual を編集するだけです。
〜/etc/postfix/virtual〜
ashiyu.no-ip.com old_main_domain
ashiyu@ashiyu.no-ip.com ashiyu
webmaster@ashiyu.no-ip.com webmaster
|
1行目は特に意味はないようです。(コメント的なもの)
2,3行目は指定メールアドレス宛のメールを指定ユーザへ配送するという意味です。
あとは、データベースを作成してvirtualの設定を有効にするためにpostmapコマンドを実行、その後Postfixの再起動を行う。
postmap /etc/postfix/virtual
/etc/rc.d/init.d/postfix restart
|
34.3.ネームサーバの設定
ネームサーバも、ashiyu.no-ip.com 部分をashiyu.net に変更します。
本来は内向きLAN用として、複数ドメイン分ゾーンファイルを用意したいところなんだけど、ashiyu.no-ip.comは
今後内向きでアクセスすることは皆無に等しいため、内向き用もashiyu.netのみ用意することにします。
〜/etc/named.conf〜
options {
directory "/var/named";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
};
//
// a caching only nameserver config
// 世界のDNS設定
//
zone "." IN {
type hint;
file "named.ca";
};
//zone "localhost" IN {
// type master;
// file "localhost.zone";
// allow-update { none; };
//};
// ローカルの設定
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
};
// 自ドメインの逆引きファイル
zone "1.168.192.in-addr.arpa" IN {
type master;
file "named.lan.rev";
};
// 自ドメインのゾーンファイル
zone "ashiyu.net" IN {
type master;
file "named.ashiyunet.zone";
};
//以下はコメントアウト
//zone "ashiyu.no-ip.com" IN {
// type master;
// file "named.ashiyunoip.zone";
//};
|
そういえば、他のマシン用の設定をしてなかったので、コレを機にやっちゃいます。
〜/var/named/named.ashiyunet.zone〜
@ IN SOA ashiyu.net. root.ashiyu.net. (
2004110603 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400) ; Minimum
IN NS localhost.
localhost IN A 127.0.0.1
BRL04F IN A 192.168.1.1
junkserver IN A 192.168.1.2
WLA-11G IN A 192.168.1.3
leftover IN A 192.168.1.4
a7v8x IN A 192.168.1.5
polo IN A 192.168.1.6
thinkpad IN A 192.168.1.7
portege300 IN A 192.168.1.8
pc9821ce IN A 192.168.1.9
; CNAMEよりA 指定のほうがいいみたい
mail IN A 192.168.1.2
www IN A 192.168.1.2
ftp IN A 192.168.1.2
;mail IN CNAME junkserver
;www IN CNAME junkserver
;ftp IN CNAME junkserver
|
どこで見たか覚えてないんだけど、CNAMEよりAのほうがいいみたい。
そのときは、そこに書かれてある理由からすげぇ納得したんだけど、内容をすっかり忘れてしまった。(w
まぁ、不都合も無さそうなんで、CNAMEから変更。
この正引き設定から、逆引きファイルも以下のように修正。
〜/var/named/named.lan.rev〜
@ IN SOA ashiyu.net. root.ashiyu.net. (
2004110603 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400) ; Minimum
IN NS localhost.
1 IN PTR BRL04F.ashiyu.net.
2 IN PTR junkserver.ashiyu.net.
3 IN PTR WLA-11G.ashiyu.net.
4 IN PTR leftover.ashiyu.net.
5 IN PTR a7v8x.ashiyu.net.
6 IN PTR polo.ashiyu.net.
7 IN PTR thinkpad.ashiyu.net.
8 IN PTR portege300.ashiyu.net.
9 IN PTR pc9821ce.ashiyu.net.
|
nslookup で適当にテストしたけど、これで良さそう。
あとは、resolv.confを修正すれば終わり。
〜/etc/resolv.conf〜
domain ashiyu.net
search ashiyu.net ashiyu.no-ip.com
nameserver 192.168.1.2
##search ashiyu.no-ip.com
|
これで移行して8ヶ月ほど経つんだけど、何か不具合ありますかねぇ?(藁)
個人的には無さそう(logとか見る限り)なんだけど、オレが気付いてないところで、妙な不具合がありそうな予感…。
管理人の戯言トップ |
ホームに戻る |