Apacheロケーション認証による不正アクセスを許可する

Apacheロケーション認証による不正アクセスを許可する

私はApache/2.2.22を実行しています。

Apache認証要件を正しく実装する方法がわかりません。

私のウェブサイトには2つの分野があります。

  1. アクセスには常にパスワード認証が必要です(/restrictedおよび/cgi-bin/restricted)。
  2. ローカルIPアドレス(/localおよび/cgi-bin/local)に基づいてアクセスを許可できます。

しかし、私は次のような行動をとります。

  • /restricted/index.htmlへの正しいアクセスには認証が必要です。
  • /cgi-bin/restrict/への正しいアクセスには認証が必要です。
  • /cgi-bin/restricted/target.cgi アクセスに認証は必要ありません。

これらのテストはすべて、実際には/localおよび/cgi-bin/localへのアクセスが許可されているIPアドレスで行われているため、何らかの方法で制限を超える可能性がありますが、絶対にしてはいけません。

私のVirtualHost設定の関連部分は次のとおりです。 (現在、<Location />cgi-binセクションでsを使用しており、以前は関連sのすべての要件がありましたが、<Directory />私が見つけた他の提案に基づいてこれを削除しました。効果はありません。)

DocumentRoot /var/www

    # HTML section
    <Directory /var/www/restricted>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            AuthType Basic
            AuthName "Restricted"
            AuthBasicProvider file
            AuthUserFile /etc/apache2/passwords
            Require user username
    </Directory>

    <Directory "/var/www/local/">
            Options Indexes FollowSymLinks
            Order allow,deny
            Allow from 192.168.1.0/24
            Allow from 192.168.0.0/24
    </Directory>

    # CGI section
    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

    <Directory "/usr/lib/cgi-bin/resricted">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    </Directory>

    <Location "/usr/lib/cgi-bin/restricted">
            AuthType Basic
            AuthName "Restricted"
            AuthBasicProvider file
            AuthUserFile /etc/apache2/passwords
            Order allow,deny
            Require user username
    </Location>

    <Directory "/usr/lib/cgi-bin/local">
            AllowOverride None
            Options +ExecCGI +SymLinksIfOwnerMatch -MultiViews
    </Directory>

    <Location "/usr/lib/cgi-bin/local">
            Order allow,deny
            Allow from 192.168.1.0/24
            Allow from 192.168.0.0/24
    </Location>

ベストアンサー1

#<Location "/usr/lib/cgi-bin/restricted">
<Location "/cgi-bin/restricted">
#<Location "/usr/lib/cgi-bin/local">
<Location "/cgi-bin/local">

「場所」とは、URLに含まれるパス、つまりfsディレクトリではなくホスト名の後に/で始まる部分を意味します。

おすすめ記事