42

http://httpd.apache.org/docs/trunk/mod/mod_authn_core.html#authtype谈论“AuthType None”,并有一个很好的例子说明我需要做什么 - 不幸的是,它似乎是 2.3 的新手/2.4。2.2中是否有任何等效功能?

身份验证类型 None 禁用身份验证。启用身份验证后,它通常由每个后续配置部分继承,除非指定了不同的身份验证类型。如果已验证部分的子部分不需要验证,则可以使用验证类型 None;在以下示例中,客户端可以访问 /www/docs/public 目录而无需进行身份验证:

<Directory /www/docs> 
AuthType Basic
AuthName Documents
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user 
</Directory>

<Directory /www/docs/public>
AuthType None
Require all granted
</Directory>
4

6 回答 6

102

像下面这样的东西对我来说适用于 apache 2.2。我从http://httpd.apache.org/docs/2.2/mod/core.html#require

<Directory /www/docs>
    AuthType Basic
    AuthName Documents
    AuthBasicProvider file
    AuthUserFile /usr/local/apache/passwd/passwords
    Require valid-user 
</Directory>
<Directory /www/docs/public>
    # All access controls and authentication are disabled
    # in this directory
    Satisfy Any
    Allow from all
</Directory>
于 2011-05-25T18:46:02.607 回答
9

您只需要设置 Allow from all 并 Satisfy Any

这对我有用:

Alias /example "/opt/example.com"

<Directory "/opt/example.com">
  Options None
  AllowOverride None
  Order allow,deny
  Allow from all
  Satisfy Any
</Directory>
于 2012-08-07T21:24:38.137 回答
8
<Directory /www/docs/public>
AuthType None
Require all granted
Satisfy Any
</Directory>

这将起作用

于 2010-04-22T07:50:47.647 回答
2

只是想添加一点信息:

在 Apache 2.2.22 上,您需要正确的顺序才能使其工作:

对于位置“/foo/sub”,这对我不起作用:

Satisfy Any
Allow from all

即,仍然应用来自“/foo/sub”之前定义的位置“/foo”的身份验证。

这适用于位置“/foo/sub”:

Allow from all
Satisfy Any

即,来自“/foo/sub”之前定义的位置“/foo”的身份验证被取消。

于 2017-06-21T06:40:12.740 回答
1

这在 apache2.2 上对我有用:

    <Location /trac>
       #....
       AuthType Basic
       AuthName "BLA domain"
       AuthUserFile /etc/.passwd
       Require valid-user
       Allow from all
       Satisfy Any
    </Location>
于 2011-07-28T08:42:12.870 回答
1

我认为你是对的:apache 2.2 不支持它。

我会在https://issues.apache.org/bugzilla/show_bug.cgi?id=10932尝试丑陋的解决方法

就像是:

<DirectoryMatch "^/www/docs/(?!public)"> 
AuthType Basic
AuthName Documents
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user 
</Directory>

或者

<DirectoryMatch "^/www/docs/[^p][^u][^b][^l][^i][^c]"> 
AuthType Basic
AuthName Documents
AuthBasicProvider file
AuthUserFile /usr/local/apache/passwd/passwords
Require valid-user 
</Directory>
于 2010-08-24T19:04:00.810 回答