« 12月25日の行動 | メイン | 12月28日の行動 »
2009年12月25日
[技術] Apacheのリバースプロキシーでの基本認証
【覚え書】
Apacheで、リバースプロキシーしているときに、アクセスに対して、基本認証したい場合は、<Proxy>ディレクティブを記述して、そのなかにアクセス関連の設定する。
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /data/example
ServerName www.example.com
#
CustomLog logs/example_access_log combined
ErrorLog logs/example_error_log
<Proxy *>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews Indexes SymLinksIfOwnerMatch
AuthType Basic
AuthName "Password for www.example.com"
AuthUserFile /etc/httpd/conf/www_example_com_passwd
Require valid-user
</Proxy>
# Reverse Proxy
ProxyPass / http://192.168.0.200:3000/
ProxyPassReverse / http://192.168.0.200:3000/
</VirtualHost>
あと、特定のIPアドレスは基本認証をスルーして、アクセスさせる場合は、Proxyディレクティブ内に以下のように記述する。
Allow from 192.168.0.10 Satisfy Any
また、特定のパスだけは認証なしで、アクセスOKにするには、公開するパスを記述したProxyディレクティブを追加する。
<Proxy http://192.168.0.200:3002/public/*>
Allow from all
Satisfy Any
</Proxy>
関連ドキュメント
http://httpd.apache.org/docs/2.2/ja/mod/mod_proxy.html
投稿者 nekobara : 2009年12月25日 15:16