【发布时间】:2016-02-18 04:24:17
【问题描述】:
我正在尝试满足以下要求(在 Apache HTTPD 2.2 中):
- 如果 HTTP 方法不是 HEAD、POST 或 GET,则不允许访问,无论以下任何情况。
- 如果用户是内部用户,则在没有基本身份验证质询的情况下允许访问。
- 如果用户是外部用户,则使用基本身份验证进行质询,如果他们有良好的凭据则允许进入。
这是我尝试过的众多事情之一,但我尝试过的所有事情都没有达到所有三个要求:
<Directory /path/to/wwwroot>
Options FollowSymLinks
AllowOverride FileInfo
# Basic Authentication
AuthType Basic
AuthName "Enter your site username and password."
AuthUserFile /path/to/stage.passwords
AuthGroupFile /path/to/stage.groups
Require group stageusers
# there's more logic for this variable in the real virtual_host.
# for this simplified example, manually set (using the following)
# or unset (using !internal_user).
SetEnv internal_user
Order deny,allow
Deny from all
Allow from env=internal_user
<LimitExcept HEAD POST GET>
Deny from all
</LimitExcept>
Satisfy all
</Directory>
我已阅读有关 Satisfy、Limit、LimitExcept、Order 和基本身份验证的文档,但我无法将这些部分组合在一起。
有什么可行的方法来做到这一点?
【问题讨论】:
标签: apache virtualhost basic-authentication http-method