Jam*_*son 5 apache virtualhost basic-authentication http-method
我正在尝试满足以下要求(在Apache HTTPD 2.2中):
这是我尝试过的很多事情之一,但我尝试的所有事情都没有达到所有这三个要求:
<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>
Run Code Online (Sandbox Code Playgroud)
我已阅读有关满足,限制,限制,订单和基本身份验证的文档,但我无法将各个部分放在一起.
有什么可行的方法呢?
AFAICT 在 Apache 2.2 中,您需要返回到“满足任意”方法,然后使用 mod_rewrite 处理方法检查。这是最好的路线,因为您的方法检查是完全独立的。
在2.4中,Limit/LimitExcept被mod_allowmethods替换/简化,但require也可以直接检查方法。那里要简单得多。
重写部分非常简单:
RewriteEngine ON
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|POST)$
RewriteRule .* - [F]
Run Code Online (Sandbox Code Playgroud)
但您需要确保它出现在可以访问该目录的每个虚拟主机+主服务器中,这与其他指令不同。
# Only allow expected HTTP methods.
RewriteCond %{REQUEST_METHOD} !^(GET|HEAD|POST)$
RewriteRule .* - [F]
<Directory /path/to/wwwroot>
Options FollowSymLinks
AllowOverride FileInfo
Satisfy any
# 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
</Directory>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
579 次 |
| 最近记录: |