Apacheの特定ディレクトリへのアクセス制限の記述方法について、質問になります。
環境は、apache:2.4.39 です。
現在、ドキュメントルート配下のディレクトリに、以下のようなIPによるアクセス制限をかけています。
httpd.conf:
DocumentRoot "/var/inetpub2/wwwroot"
<Directory />
Options None
AllowOverride none
Require all denied
</Directory>
<Directory "/var/inetpub2/wwwroot">
Options None
AllowOverride None
Require ip 192.168.0.AA
Require ip 192.168.0.BB
</Directory>
この状態から、新たにwwwroot直下に1つディレクトリを増やし、そのディレクトリは権限を全許可にしたいと考えています。
構成としては以下になります。
wwwroot/html1/test.html ←IP制限
wwwroot/html2/test.html ←IP制限
wwwroot/html3/test.html ←全許可
この場合、httpd.confのディレクトリタブの記載方法としては、以下の変更を想定しています。
httpd.conf
DocumentRoot "/var/inetpub2/wwwroot"
<Directory />
Options None
AllowOverride none
Require all denied
</Directory>
<Directory "/var/inetpub2/wwwroot/html1">
Options None
AllowOverride None
Require ip 192.168.0.AA
Require ip 192.168.0.BB
</Directory>
<Directory "/var/inetpub2/wwwroot/html2">
Options None
AllowOverride None
Require ip 192.168.0.AA
Require ip 192.168.0.BB
</Directory>
<Directory "/var/inetpub2/wwwroot/html3">
Options None
AllowOverride None
Require all granted
</Directory>
書き換え後、テストをして html3/index.html にはどの端末からもアクセスでき、
html1/index.html と html2/index.html には 192.168.0.AA と192.168.0.BB の端末からしか
アクセスできないことは確認できました。
httpd.confでのアクセス制限としては、
上記のディレクトリの書き方がベターでしょうか?
何か他の記述方法や懸念する点などあれば、教えていただきたいと思います。
よろしくお願いします。
あなたの回答
tips
プレビュー