mod_authz_basic 與 CloudFront(原:mod_authz basic 目錄與虛擬主機位置)

mod_authz_basic 與 CloudFront(原:mod_authz basic 目錄與虛擬主機位置)

我在使用 Apache 基本驗證時遇到問題。我有一台 EC2 伺服器位於 AWS 彈性負載平衡器和 CloudFront 後面。我在機器上運行多個域。我使用 Apache 基本驗證來存取某些區域,但所有區域都使用相同的 htpassd 和 htgroups 檔案。它對於一個網域工作正常,限制對完整子網域的訪問,但對於另一個網域,它不適用於限制對某個位置的訪問(或者,它工作得太好了 - 我無法訪問)。

環境:Apache 2.4.43 OpenSSL 1.0.2k-fips SVN 1.14.0 PHP 7.4.5

location故障模式適用於conf.d/subversion.conf中定義的Apache :

   <Location /repos>
   DAV svn
   SVNParentPath /var/svn/
   SVNListParentPath On
   LogLevel debug
  Options All
  AllowOverride All Options

  AuthType Basic
  AuthName "Subversion Repository"
  AuthUserFile /mnt/data/etc/htpasswd
  AuthGroupFile /mnt/data/etc/htgroups
  Require group subversion

並且錯誤文件顯示

[Mon Aug 17 00:04:47.658169 2020] [authz_core:debug] [pid 30612] mod_authz_core.c(818): [client 10.0.200.51:11378] AH01626: authorization result of Require group subversion: denied (no authenticated user yet)
[Mon Aug 17 00:04:47.658511 2020] [authz_core:debug] [pid 30612] mod_authz_core.c(818): [client 10.0.200.51:11378] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)
[Mon Aug 17 00:04:54.816887 2020] [authz_core:debug] [pid 30548] mod_authz_core.c(818): [client 10.0.200.51:11382] AH01626: authorization result of Require group subversion: denied (no authenticated user yet)
[Mon Aug 17 00:04:54.817233 2020] [authz_core:debug] [pid 30548] mod_authz_core.c(818): [client 10.0.200.51:11382] AH01626: authorization result of <RequireAny>: denied (no authenticated user yet)

在 conf.d/vhost.conf 檔案中www.myhost.com,我試圖www.myhost.com/repos使用上述 SVN 配置來實現,我也有

    <Directory />
            Options All
            #Allow from All
            #Order Allow,Deny
            Require all granted
            AllowOverride All Options
            ...

在我記得(並確認)我在同一 EC2 主機和 Apache 實例上的不同場景中使用相同的身份驗證機制之前,我花了很長時間運行各種老鼠洞。這在 vhost.conf 中運作正常:

    ServerName dev.anotherdomain.com
    <Directory />
            Options All
            #Allow from All
            #Order Allow,Deny
            AllowOverride All Options

            # AuthType Digest
            AuthType Basic
            AuthName "DevAndTest"
            AuthUserFile /mnt/data/etc/htpasswd
            AuthGroupFile /mnt/data/etc/htgroups
            Require group adifferentgroup

這似乎工作正常,這讓我有點困惑:(

答案1

事實證明,問題是我需要將AuthorizationCloudfront 發行版中的標題列入白名單。原始問題中的子網域案例有效,因為它不在 Cloudfront 後面。

相關內容