jkoop
jkoop

Reputation: 133

Apache2 WebDAV writable directory in readonly server

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.

Upvotes: 4

Views: 1341

Answers (1)

jkoop
jkoop

Reputation: 133

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.

Upvotes: 3

Related Questions