なんとなくApacheの設定の理解が3割り増しになった気がする。たぶん幻覚。
以下、ReverseProxy鯖の設定例。
- /awstats へのアクセスはReverseProxy鯖自信のawstatsへ(アクセス解析情報の閲覧)
- specialuser.example.net でアクセスされた場合は無条件でvmserverに飛ばす
- ~specialuser もvmserverに任せる(specialuser.example.net/~specialuserに飛ばす)
- その他は192.168.0.n = example.net鯖が担当
「リクエストが どの ServerName ディレクティブにもマッチしない場合、 一番最初の VirtualHost により扱われます」とのことなので、2番目を下に独立させた。
~specialuserとspecialuser.example.netで名前が一致しているのがキモイかもしれないけど、あとはたぶん普通?
NameVirtualHost *:80ServerAdmin www-admin@example.net ServerName example.net # awstatsを動かす場所ではCGIが実行できるようにする # specialuser.example.net鯖の設定(単純な名前ベースVirtualHost)Options ExecCGI AllowOverride None Order allow,deny Allow from all # 知らない人にのぞかれちゃいやん AuthType Basic AuthName “private” AuthUserFile “/path_to_awstats/.htpasswd.awstats” require valid-user Alias /awstats-icon/ “/path_to_awstats/icon/” ScriptAlias /awstats/ “/path_to_awstats/cgi-bin/” # /awstats にはProxyルールを適用しない ProxyPass /awstats ! # 3番目のルール ProxyPass /~specialuser http://vmserver/~specialuser ProxyPassReverse /~specialuser http://vmserver/~specialuser # 4番目のルール ProxyPass / http://192.168.0.n/ ProxyPassReverse / http://192.168.0.n/ ErrorLog /var/log/httpd-all-error_log CustomLog /var/log/httpd-all-access_log commonServerAdmin www-admin@example.net ServerName specialuser.example.net ProxyPass / http://vmserver/ ProxyPassReverse / http://vmserver/ ErrorLog /var/log/httpd-specialuser-error_log CustomLog /var/log/httpd-specialuser-access_log common