WebDAV 和 Windows 7 客户端

WebDAV 和 Windows 7 客户端

我已在我的网站上启用了 apache dav 模块并为其配置了摘要式身份验证。现在我正尝试将 Windows 驱动器连接到它。命令如下:

net use z: http://dav.mysite.com/Files /user:username *

然后它要求输入密码。之后驱动器似乎已连接,但有一个细节除外。在服务器日志中,我可以看到奇怪的 401 错误:

xx.xx.xx.xx - - [22/Mar/2011:23:05:04 +0000] "PROPFIND /Files HTTP/1.0" 401 751
xx.xx.xx.xx - username [22/Mar/2011:23:05:04 +0000] "PROPFIND /Files HTTP/1.0" 301 495
xx.xx.xx.xx - - [22/Mar/2011:23:05:04 +0000] "PROPFIND /Files/ HTTP/1.0" 401 751
xx.xx.xx.xx - username [22/Mar/2011:23:05:04 +0000] "PROPFIND /Files/ HTTP/1.0" 207 1175
xx.xx.xx.xx - - [22/Mar/2011:23:05:07 +0000] "PROPFIND /Files HTTP/1.0" 401 751
xx.xx.xx.xx - username [22/Mar/2011:23:05:07 +0000] "PROPFIND /Files HTTP/1.0" 301 495
xx.xx.xx.xx - - [22/Mar/2011:23:05:07 +0000] "PROPFIND /Files/ HTTP/1.0" 401 751
xx.xx.xx.xx - username [22/Mar/2011:23:05:07 +0000] "PROPFIND /Files/ HTTP/1.0" 207 1175

正如您所看到的,任何正确的摘要认证请求都会发送一个错误的请求

我的Apache配置:

<VirtualHost xx.xx.xx.xx:80>
        ServerAdmin [email protected]
        ServerName dav.dav.mysite.com
        DocumentRoot /var/www/dav.mysite.com/
        UseCanonicalName Off

        Alias /Files "/var/www/dav.mysite.com/"



        BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
        BrowserMatch "MS FrontPage" redirect-carefully
        BrowserMatch "^WebDrive" redirect-carefully
        BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully
        BrowserMatch "^gnome-vfs/1.0" redirect-carefully
        BrowserMatch "^XML Spy" redirect-carefully
        BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
        BrowserMatch "MSIE" AuthDigestEnableQueryStringHack=On


        <Directory "/var/www/dav.mysite.com">
                Dav On
                Order allow,deny
                Allow from all
                AuthType Digest
                AuthName "DAV-upload"
                AuthDigestDomain /Files/
                AuthDigestProvider file
                AuthUserFile /var/www/webdav.passwd
                Require valid-user
        </Directory>

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel error
        ErrorLog /var/log/apache2/dav.dav.mysite.com-error.log
        CustomLog /var/log/apache2/dav.dav.mysite.com.log common
        ServerSignature Off
</VirtualHost>

而且它运行非常非常慢。你认为它为什么会发送没有身份验证的请求?顺便说一句,其他 webdav 客户端运行正常

PS:nginx 位于 apache 前面,将所有流量传递给它

答案1

欢迎来到巨大的痛苦。我遇到了同样的问题,并在 Windows 中解决了它。首先是转到 Internet Explorer,然后转到工具 Internet 选项。转到连接选项卡并查看我相信的局域网设置。在这里查看是否选中了“自动检测局域网设置”。如果是,请取消选中。这将解决速度问题。如果您仍然看到问题再次出现,我会给您更多想法。

答案2

我找到了一个答案,这显然是设计使然:每个请求都要进行身份验证。我实施的一个解决方法是允许匿名目录/文件列表(PROPFIND 请求)并使用下面显示的 Apache 配置对其他所有内容进行身份验证。速度提升非常显著,对于包含 21876 个文件的 Python 项目,刷新时间缩短了一半,为 11 分钟,而使用身份验证则需要 22 分钟。

## Development HTTP Site
<VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName development.FOO.com
        ServerAlias www.development.FOO.com

        # Log file location and settings; logs within project is ok as long as 'links' are made to system 'var/log/apache'
        ErrorLog /var/log/apache2/development.FOO.com-error.log
        CustomLog /var/log/apache2/development.FOO.com-vhost_combined-access.log vhost_combined

        # Canonical to always strip www - see: https://stackoverflow.com/questions/88011/make-apache-automatically-strip-off-the-www
        RewriteCond %{HTTP_HOST} ^www\.(.+)$
        RewriteRule ^(.*)$ ${SERVER_PROTOCOL}://%1/$1 [R=301,L,NC]

        # Authenticated access for the development site version - because without this Google will find you!
        # Just in case we also prevent serving of the password logins file if it is stored in a serving folder.
        Redirect /apache-logins.htdigest http://development.FOO.com
        <Location />
                DAV On
                DirectoryIndex disabled
                Options +Indexes
                AuthType Digest
                AuthName "development.FOO.com"
                # AuthDigestDomain which urls (and any under it) this applies - should match location
                AuthDigestDomain /
                AuthDigestProvider file
                AuthUserFile /srv/www/django/development.FOO.com/apache-logins.htdigest
                # uncomment the LimitExcept to receive a small boost for non caching Windows WebDav client by allowing
                # anonymous directory listing; see http://serverfault.com/questions/250578/webdav-and-windows-7-client
                <LimitExcept PROPFIND>
                    Require valid-user
                </LimitExcept>
        </Location>

        WSGIProcessGroup development.FOO.com
        # You can further limit processes, threads and set a inactivity-timer so deamon get unloaded
        WSGIDaemonProcess development.FOO.com display-name=%{GROUP}
        WSGIScriptAlias / /srv/www/django/development.FOO.com/apache-django-development.wsgi

        # Serve static / media files through apache instance and alias/map them to specific urls. to maximize security
        # `Options -Indexes` is enabled to prevent directory listing
        Options -Indexes
        Alias /robots.txt /srv/www/django/development.FOO.com/src/django-project/static/robots.txt
    #Alias /sitemap.xml /srv/www/django/development.FOO.com/src/django-project/static/sitemap.xml
        Alias /favicon.ico /srv/www/django/development.FOO.com/src/django-project/static/favicon.ico
        Alias /media /srv/www/django/development.FOO.com/src/django-project/static/
        Alias /static /srv/www/django/development.FOO.com/src/django-project/static/

</VirtualHost>

以下是更多信息:https://stackoverflow.com/questions/666553/how-to-avoid-windows-vista-to-do-double-webdav-requests

相关内容