ひとつの変動IPで2つ以上の ホスト名を動か し、
さらにVirtualhostでイントラ内の鯖を見せる方法


Dyndns.orgでは、最大で5つまでのホスト名を指定することが可能だ。
http://www.dyndns.com/services/dns/dyndns/より引用:
The free Dynamic DNS service allows you to alias a dynamic IP address to a static hostname in any of the many domains we offer, allowing your computer to be more easily accessed from various locations on the Internet. We provide this service, for up to five (5) hostnames, free to the Internet community.
(以下略)
 
プロバイダから与えられたIPアドレスが1つでも、VirtualhostとDocumentRootを組み合わせることにより、リクエストされたホス ト名によって見せるページを変化させることができる。Virtualhostのサーバ名がリクエストされたとき、見せるべきDocumentRoot を指定する。
さらにこれを拡張することができる。例えば、外部から夫々違うホスト名でリクエストがあったときに、プロクシの機能であるProxyPassと ProxyPassReverseを使って、防火壁内(外に晒していない)の、複数のイントラネットのサーバに振り分けて、母艦のプロキシで外に公開する ことができる。

virtualhost.gif


要は、外側からの80番ポートへの処理は
http://horie.homeunix.com /     図中のApache1号機
が行うが、
http://beach.homelinux.org /     図中のApache2号機
へのリクエストがあったとき、イントラネット内の
図中のApache2号機 (イントラネット内からのみ参照可)
のApacheにproxyするということだ。

 
具体的な書式としては、こんな感じ。赤い 字 の部分が今回の設 定。
/usr/local/etc/apache22/extra/httpd-vhosts.conf として保存した。


NameVirtualHost *:80

#IPアドレス直で来訪したのはattackと見做す
<VirtualHost *:80>
    CustomLog /var/log/httpd_attack_log common
    ErrorLog /var/log/httpd_attack_error
</VirtualHost>

#自鯖へのアクセスは、普通のDocumentRootを誘導
<VirtualHost *:80>
    DocumentRoot "/usr/local/www/data"
    ServerAdmin net-admin@horie.homeunix.com
    ServerName horie.homeunix.com
</VirtualHost>

#自鯖の別名へのアクセスには別のDocumentRootに誘導
<VirtualHost *:80>
    DocumentRoot "/usr/local/www/data/yyp"
    ScriptAlias /cgi-bin/ "/usr/local/www/data/yyp/cgi-bin/"
    ServerAdmin net-admin@horie.homeunix.com

    ServerName ja1yyp.homeunix.com
</VirtualHost>

#別鯖へのアクセスにはProxyで誘導
<VirtualHost *:80>
    ProxyPass / http://192.168.0.2/
    ProxyPassReverse / http://192.168.0.2/
    ServerAdmin net-admin@beach.homelinux.org
    ServerName beach.homelinux.org
</VirtualHost>




2007/03/21 horie
ちっと書き直し 2008/2/2 horie
トップに戻る