2014-06-17 21 views
0

問題錯誤與子域基本驗證:

我已經Laravel在Apache 2.4.9運行和我的域結構如下:通過htpasswd的

beta.domain.com => /var/www/beta 
www.domain.com  => /var/www/live 

貝塔子域具有基本身份驗證。除了當我開始撥動apache2錯誤日誌時,一切都按預期工作。我收到以下錯誤信息:

AH01797: /var/www/beta/public/index.php,引用者:https://beta.domain.com/

我的設置:

客戶端通過服務器配置拒絕

這裏是我的設置:

<VirtualHost *:80> 

    # Redirect all http traffic to https 

    Redirect 301/https://www.domain.com/ 

</VirtualHost> 

<VirtualHost *:443> 

    # some SSL setup for www here 

    ServerName www.domain.com 

    DocumentRoot /var/www/live/public 
    <Directory /var/www/live/public> 
     Options Indexes FollowSymLinks 
     AllowOverride All 
     Order allow,deny 
     Allow from all 
    </Directory> 


    LogLevel warn 

    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 

    SetEnv ENVIRONMENT "live" 

</VirtualHost> 

<VirtualHost *:443> 

    # some SSL setup for beta here 

    ServerName beta.domain.com 

    DocumentRoot /var/www/beta/public 
    <Directory /var/www/beta/public> 
     Options Indexes FollowSymLinks MultiViews 
     AllowOverride All 
     Order allow,deny 

     # allow from one ip 
     Allow from xxx.xxx.xxx 
     Satisfy any 

     AuthUserFile /path/to/htpasswd/.htpasswd 
     AuthName "Password required" 
     AuthType Basic 
     Require valid-user 

    </Directory> 


    LogLevel warn 

    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 

    SetEnv ENVIRONMENT "beta" 

</VirtualHost> 

失敗的嘗試:

我發現了幾個不同的答案,沒有一個適合我。這些看起來是最有說服力的,但它們又一次不適合我。

  1. <Location>標籤(http://httpd.apache.org/docs/current/mod/mod_auth_basic.html#authbasicprovider)更換<Directory> - 錯誤都不見了,但我失去了基本的身份驗證

  2. 使用Require all granted,而不是Order allow/deny - 這也 除去我基本身份驗證。也不知道這是否使 在我的方案中有意義。

回答

0

因爲我使用Apache 2.4及以上的,我改變了

Order allow, deny 
Allow from all 

簡單

Require all granted 

這修復該錯誤消息,但允許在測試子域基本身份驗證,我也必須刪除Satisfy any

因此,beta的設置將更改爲:

<Directory /var/www/beta/public> 

    Options Indexes FollowSymLinks MultiViews 
    AllowOverride All 
    # removed in 2.4 
    # Order allow,deny 

    # allow from one ip 
    Require ip xxx.xxx.xxx 
    # No longer require Satisfy any in 2.4 
    # Satisfy any 

    AuthUserFile /path/to/htpasswd/.htpasswd 
    AuthName "Password required" 
    AuthType Basic 
    Require valid-user 

</Directory>