特定のIPに対してApache認証をバイパスする

特定のIPに対してApache認証をバイパスする

Apacheをリバースプロキシとして使用するため、内部開発/テストサーバーの一部は、UAT / CAT目的でパブリックインターネットからアクセスできます。

LDAPサーバーを介した基本認証設定がありますが、認証なしでサーバーにアクセスできるようにホワイトリストに特定のIPを追加する必要があるサイトがいくつかあります。

現在のセクションの上にこのような他のセクションを追加することが可能かどうかはわかりません。

<proxy *>
 Require all granted
 Require ip x.x.x.x y.y.y.y
</proxy>

現在のファイルは次のとおりです.conf

<VirtualHost *:80>
  ServerName some.server.url

  ## Vhost docroot
  DocumentRoot "/var/www"

  ## Directories, there should at least be a declaration for /var/www

  <Directory "/var/www">
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Require all granted
  </Directory>

  ## Logging
  ErrorLog "/var/log/httpd/some.server.url_error.log"
  ServerSignature Off
  CustomLog "/var/log/httpd/some.server.url_access.log" combined

  ## Proxy rules
  ProxyRequests Off
  ProxyPreserveHost Off
  ProxyPass /robots.txt !
  ProxyPassReverse /robots.txt !
  ProxyPass / https://some.server.url/ acquire=3000 keepalive=On retry=0 timeout=1800
  ProxyPassReverse / https://some.server.url/

  ## Custom fragment
  <proxy *>
    AuthBasicProvider ldap-client-websites ldap-sidlee-dig
    AuthType Basic
    AuthName "GRM CRHA UAT"
    Require valid-user
  </proxy>

</VirtualHost>

ベストアンサー1

<proxy *>いいえ。 2番目のブロックは最初のブロックと衝突するので、追加しないでください。

代わりに、<proxy *>既存のブロックを次に変更してください。

## Custom fragment
<proxy *>
    AuthBasicProvider ldap-client-websites ldap-sidlee-dig
    AuthType Basic
    AuthName "GRM CRHA UAT"
    <RequireAny>
        Require ip x.x.x.x y.y.y.y
        Require valid-user
    </RequireAny>
</proxy>

</VirtualHost>

Requireこれにより、ディレクティブの 1 つだけを満たしても<RequireAny>アクセスが許可されます。だから、誰でも一致するIPアドレスがありますまたはアクセスを許可するには、成功した認証が必要です。

おすすめ記事