Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache2 WebDAV writable directory in readonly server

Tags:

apache2

webdav

To serve files, I set up a readonly WebDAV with Apache2 serving from davs://dav.example.com/. However, I want a subdirectory (davs://dav.example.com/uploads/) that is writable by the logged in user.

To make my site readonly, I used the following:

  ...

<Directory /var/www/dav>
    Options +Indexes

    DAV On

    Order allow,deny
    AuthType Basic
    AuthName "Not for public access!  Login only"
    AuthUserFile /var/www/htpasswd

    <Limit GET OPTIONS PROPFIND>
        Require valid-user
        Deny from all
    </Limit>

    <Limit PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
        Require host dav.example.com
        Deny from all
    </Limit>

    Satisfy Any
</Directory>

  ...

I've tried making <Directory /var/www/dav/upload>, copying the <Limit PUT... with Require valid-user in it, but that didn't work. When creating a file in the /upload/ dir, the server responded with a 500 error.

Is this possible? I have access to the site.conf file.

like image 401
jkoop Avatar asked Oct 14 '25 07:10

jkoop


1 Answers

Make a <Directory /var/www/dav/upload> block with this in it:

<LimitExcept GET OPTIONS PROPFIND PUT POST DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
    Require valid-user
    Deny from all
</LimitExcept>

This also works in .htaccess files, if needed.

like image 133
jkoop Avatar answered Oct 18 '25 10:10

jkoop



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!