我让Laravel在Apache 2.4.9上运行,我的域名组织如下:
beta.domain.com => /var/www/beta
www.domain.com => /var/www/live
beta子域具有基本身份验证。除非我开始探索apache2错误日志,否则一切都按预期工作。我收到以下错误消息:
AH01797:服务器配置拒绝客户端: /var/www/beta/public/index.php,referer: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>
我找到了几个不同的答案,但没有一个对我有用。这些似乎是最有说服力的,但它们再次对我没用。
用<Directory>
标签(http://httpd.apache.org/docs/current/mod/mod_auth_basic.html#authbasicprovider)替换<Location>
- 错误消失了,但我丢失了基本身份验证
使用Require all granted
代替Order allow/deny
- 这也是
删除了我的基本身份验证。也不确定这是否成功
在我的场景中有意义。
答案 0 :(得分:0)
因为我使用的是Apache 2.4+,所以我改变了
Order allow, deny
Allow from all
简单地
Require all granted
这会修复错误消息,但为了允许在beta子域上进行基本身份验证,我还必须删除Satisfy any
因此,测试版的设置将更改为:
<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>