WebDav-浏览器禁止

WebDav-浏览器禁止

我正在尝试使用 raspberry pi 创建服务器,但在此之前,我决定先在虚拟机中测试它。因此,我在 /var/www/ 中创建了两个文件夹 webdav 和 webdav2,它们运行良好(Chrome 和 nautilus 显示其内容,我也可以向其中添加文件)。但是,当我尝试在 /mnt/webdav_share 中创建服务器时,却没有获得同样的成功。我可以在 Nautilus 上访问它,但在 Chrome 中,我收到“禁止访问 - 您无权访问此资源”的提示。

这是我的配置文件:

    <VirtualHost *:80>
    # The ServerName directive sets the request scheme, hostname and port that
    # the server uses to identify itself. This is used when creating
    # redirection URLs. In the context of virtual hosts, the ServerName
    # specifies what hostname must appear in the request's Host: header to
    # match this virtual host. For the default virtual host (this file) this
    # value is not decisive as it is used as a last resort host regardless.
    # However, you must set it for any further virtual host explicitly.
    #ServerName www.example.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
    # error, crit, alert, emerg.
    # It is also possible to configure the loglevel for particular
    # modules, e.g.
    #LogLevel info ssl:warn

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    # For most configuration files from conf-available/, which are
    # enabled or disabled at a global level, it is possible to
    # include a line for only one particular virtual host. For example the
    # following line enables the CGI configuration for this host only
    # after it has been globally disabled with "a2disconf".
    #Include conf-available/serve-cgi-bin.conf
    Alias /webdav /var/www/webdav
    <Location /webdav>
    DAV On
    AuthType Basic
    AuthName "webdav"
    AuthUserFile /var/www/webdav/passwd.dav
    Require valid-user
    </Location>

    Alias /webdav2 /var/www/webdav2
    <Location /webdav2>
    DAV On
    AuthType Basic
    AuthName "webdav2"
    AuthUserFile /var/www/webdav2/.secrets/passwd.dav
    Require valid-user
    </Location>

    Alias /webdav_share /mnt/webdav_share
    <Directory /mnt/webdav_share>
    DAV On
    AuthType Basic
    AuthName "webdav_share"
    AuthUserFile /mnt/webdav_share/.secrets/passwd.dav
    Require valid-user
    AllowOverride all
    Order allow,deny
    allow from all
    </Directory>

    </VirtualHost>

    # vim: syntax=apache ts=4 sw=4 sts=4 sr noet

文件属性

    drwxr-xr-x  5 www-data www-data 4.0K Apr  4 21:50 webdav_share
    drwxrwxr-x 2 www-data www-data 4.0K Apr  4 20:11  .secrets
    -rw-r--r-- 1 www-data www-data   44 Apr  4 20:32 passwd.dav

谢谢,

爱德华多

答案1

因此,答案就在这里:

默认情况下,Ubuntu 不允许通过 Web 浏览器访问除位于 /var/www、public_html 目录(启用时)和 /usr/share(用于 Web 应用程序)之外的任何文件。如果您的网站使用位于其他地方的 Web 文档根目录(例如 /srv),您可能需要在 /etc/apache2/apache2.conf 中将您的文档根目录列入白名单。

Ubuntu 默认的文档根目录是 /var/www/html。您可以在 /var/www 下创建自己的虚拟主机。这与以前的版本不同,它提供了更好的开箱即用安全性。

只需将我的文件夹添加到文件中,它就开始工作了

谢谢

相关内容