Apacheで特定のIPアドレス制限が効かない

2021-07-06

Basic認証とIP制限の併用でIP制限が効かない

BASIC認証とIP制限を併用しているサイトが合って、特定のファイルのみIP制限したいとの要望があって「.htaccess」に設定を入れても、IP制限が全く効かなかった。

Satisfy Any

order deny,allow
deny from all
allow from xxx.xxx.xxx.xxx
allow from xxx.xxx.xxx.xxx
allow from xxx.xxx.xxx.xxx

<Files ~ "^secret\.html$">
  order deny,allow
  deny from all
  allow from xxx.xxx.xxx.xxx
  allow from xxx.xxx.xxx.xxx
</Files>

#Basic Auth
AuthUserFile /var/www/html/.htpasswd
AuthGroupFile /dev/null
AuthName "Please enter your ID and password"
AuthType Basic
require valid-user

原因がわからず、Apacheの設定を見直したりしたけど、30分ほど悩みましたが、htaccess 内に「Satisfy Any」となっているので、IP制限かBASIC認証のどちらかの制限を許可されれば良い設定です。

IP制限かBASIC認証のどちらとも認証の必要とする場合は「Satisfy All」とすればいいみたいです

Apache : Satisfy ディレクティブ

スポンサーリンク

0
0

LinuxApache,CentOS 6,CentOS 7

Posted by admin