Apacheでディレクトリへのアクセスを許可しますが、サブディレクトリへのアクセスを許可しない方法は何ですか?

Apacheでディレクトリへのアクセスを許可しますが、サブディレクトリへのアクセスを許可しない方法は何ですか?

私はすでにこの質問をしました。Apacheメーリングリストしかし、希望の答えを得られませんでした。

2人のユーザーがIP(192.168.1.2 192.168.1.7)に基づいて "/var/www/html/ldap"ディレクトリを使用できるようにしたいと思います。

<Directory /var/www/html/ldap>
      Order allow,deny
      Allow from 192.168.1.2 192.168.1.7
      Satisfy any
      AuthName "LDAP Authentication"
      AuthType Basic

      AuthBasicProvider ldap
      AuthzLDAPauthoritative off
      AuthLDAPURL ldap://192.168.1.3/dc=example,dc=com?uid?sub?(objectClass=*)
      Require valid-user
</Directory>

しかし、サブディレクトリに192.168.1.7が存在することを許可したくありません(192.168.1.2のみが存在することを許可したい)。

私は以下を追加してみました:

<Directory /var/www/html/ldap/manager>
      Order allow,deny
      Allow from 192.168.1.2
      Satisfy any
      AuthName "LDAP Authentication"
      AuthType Basic

      AuthBasicProvider ldap
      AuthzLDAPauthoritative off
      AuthLDAPURL ldap://192.168.1.3/dc=example,dc=com?uid?sub?(objectClass=*)
      Require valid-user
</Directory>

しかし、192.168.1.7はldapディレクトリの一部であるため、管理者ディレクトリにアクセスできるようです。これをどのように禁止できますか?

修正する:

〜のようにラジャ私が試した提案は次のとおりです。

ホームディレクトリの場合:

 <Directory /var/www/html/ldap>
          Order allow,deny
          Allow from 192.168.1.2 192.168.1.7
          Satisfy any
          AuthName "LDAP Authentication"
          AuthType Basic

          AuthBasicProvider ldap
          AuthzLDAPauthoritative off
          AuthLDAPURL ldap://192.168.1.3/dc=example,dc=com?uid?sub?(objectClass=*)
          Require valid-user
    </Directory>

サブディレクトリの場合:

 <Directory /var/www/html/ldap/manager>
          Order Deny,Allow
          Deny From All
          Allow From 192.168.1.2
          Satisfy any
          AuthName "LDAP Authentication"
          AuthType Basic

          AuthBasicProvider ldap
          AuthzLDAPauthoritative off
          AuthLDAPURL ldap://192.168.1.3/dc=example,dc=com?uid?sub?(objectClass=*)
          Require valid-user
    </Directory>

メモ:

両方のディレクトリ(ホームディレクトリとサブディレクトリ)で192.168.1.2と192.168.1.7の認証(LDAP AUTH)を要求したくありません。

ベストアンサー1

192.168.1.7 システムがサブディレクトリにアクセスするのを防ぐために書き換え規則を使用するのはどうでしょうか。

RewriteEngine on
RewriteCond   %{REMOTE_ADDR}   ^192\.168\.1\.7$  [NC]
RewriteCond   %{REQUEST_URI}   ^/ldap/manager/.* [NC]
RewriteRule   ^(.*)$           -                 [R=404,L]

元の回答に基づいて編集すると、「禁止された」エラーコードが再送信されます。

おすすめ記事