client denied by server configuration
尽管 htaccess 配置按预期工作,但我们的 apache 错误日志中却充斥着这样的消息。
以下是 htaccess 的相关部分:
SetEnvIfExpr "req_novary('User-Agent') =~ /.*WHATEVER.*/" WHATEVER=1
<RequireAll>
# Only allow access for these hosts
Require expr "%{HTTP_HOST} =~ /((host1|host2|host3)\.com)/"
# Deny access if any of the rules in the RequireNone succeed!
<RequireNone>
# IIRC putting the two requires here is fine, it's an implicit OR.
Require expr "%{REQUEST_URI} =~ m#.*RELEASE_NOTES\.txt#i"
<RequireAll>
# Block path unless it's one of the User Agents we want to allow
Require expr "%{REQUEST_URI} =~ m#pathy/path#i"
# This expr is what seems to trigger the error, even though the User Agent
# matches and the server responds with a HTTP 200 code (and the request is successful).
Require expr "!(reqenv('WHATEVER') == 1)"
</RequireAll>
</RequireNone>
</RequireAll>
如果我们使用正确的用户代理进行测试,它会正常工作,我们会得到 HTTP 200,并且响应有效。如果我们使用不同的 UA,它会像预期的那样给我们一个 403 Forbidden。但每次成功的请求client denied by server configuration
都会记录错误。
我们在使用其他Require expr
语句时遇到了同样的问题,但我们将其更改为重写规则以解决该问题(此问题导致基本上每次资源访问都会出现一条日志消息)。我们可以在这里再次执行相同的操作,但我很好奇为什么这可能会导致错误。