apache2 摘要身份验证

apache2 摘要身份验证

这是我在 Ubuntu 服务器 11.10 上的站点文件:

<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/mydir
    ServerAlias *.mydomain.no-ip.info
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/mydir>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    #   SSL Engine Switch:
    #   Enable/Disable SSL for this virtual host.
    SSLEngine on

    #   A self-signed (snakeoil) certificate can be created by installing
    #   the ssl-cert package. See
    #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
    #   If both key and certificate are stored in the same file, only the
    #   SSLCertificateFile directive is needed.
    SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
 </VirtualHost>
 </IfModule>

现在我想要获得目录的授权访问:

/var/www/mydir/private

我创建了如下摘要文件:

sudo htdigest -c /etc/apache2/digest_auth users enedene

因此我在 <\Virtualhost> 之前添加了以下内容:

<Directory "/var/www/mydir/private/">
            AuthType Digest
            AuthName "Private"
            AuthDigestProvider file
            AuthUserFile /etc/apache2/digest_auth
            Require enedene
</Directory>

我重新启动了 Web 服务器并转到链接:

https://mydomain.no-ip.info/private

我得到了想要的用户名和密码提示,但问题是它不接受我创建的用户/密码,它只是不断拒绝并再次提示,好像用户名/密码组合是错误的。
我的设置有什么问题?

编辑:
这是/var/log/apache2/error.log所说的内容:

[Wed Dec 07 18:00:47 2011] [error] [client 188.129.120.255] File does not exist: /var/www/mydir/favicon.ico
[Wed Dec 07 18:01:07 2011] [error] [client 188.129.120.255] Digest: user `enedene' in realm `Private' not found: /private

第一行是当我连接到网站时,但网站可以正常工作,第二行是当我尝试访问 /var/www/mydir/private 目录时,浏览器进行了身份验证但我无法进入。

编辑 2:
将 AuthName 更改为“用户”后出现新错误:

[Wed Dec 07 18:07:59 2011] [error] [client 188.129.120.255] access to /private failed, reason: require directives present and no Authoritative handler.

答案1

我相信,由于您的领域是用户,那么您的 AuthName 指令应该是“用户”

不要尝试使用 AuthNmae“Private”,而是使用 AuthName“users”重新启动 apache;

sudo 服务 apache2 重新加载

答案2

在 AuthUserFile 之后添加以下内容:

AuthGroupFile /dev/null

重新启动 Apache 后这有帮助吗?如果没有,当身份验证失败时,${APACHE_LOG_DIR}/error.log 会说什么?

相关内容