Apache2 WebDAV for bookmark synchronization with Floccus

Goal

Use Apache as WebDAV server to allow synchronizing my browser bookmarks with the Floccus browser extension or for arbitrary data transfers

(!) Note: This setup side-steps the SSO configuration used with FreedomBox (FB) because otherwise FB would force a redirect to the login page for login - and this will not work with Floccus. If you just want a DAV folder, you may want to use mod_pub_authtkt instead (not covered here - but see all the other services your FB has for examples).

Requirements

  • Familiarity with the command line, e. g. using SSH to connect to your FreedomBox
  • SSH access to you FB, admin privileges to reload services

Steps

Log into your FB using SSH with a superuser account

ssh superuser@fb.example.org

Create a new folder where data will be stored and set proper permissions

sudo mkdir /var/lib/folder
sudo chown www-data:www-data /var/lib/folder

Create a file with credentials for access:

sudo htpasswd -c /etc/apache2/users.htaccess username
# enter password twice when prompted

Add a new Apache configuration file that exposes the new folder over DAV:

sudo vim /etc/apache2/conf-available/dav.conf

Enter the following contents into this new file (and adjust as needed for your setup):

##
## Allow WebDAV for /var/lib/folder
##

Alias /folder /var/lib/folder

<Location /folder>
    AuthType Basic
    AuthName DAV
    AuthUserFile "/etc/apache2/users.htaccess"
    Require valid-user
</Location>

<Directory /var/lib/folder>
    Dav On

    # Don't accept overrides in .htaccess
    AllowOverride None

    # Disable following symlinks, show an index page
    Options Indexes
</Directory>

Enable this new configuration:

sudo a2enconf dav

Then reload the apache2 service to activate it:

sudo systemctl reload apache2

Testing DAV access

With a file-manager that allows browsing DAV shared (e. g. Gnome’s Files app) you can try out the setup using a proper connect string:

davs://username@fb.example.org/folder

Set up Floccus

Follow the official guide for WebDAV here:

3 Likes

Thank you for the guide. One way to simplify this is to use LDAP authentication with accounts created with FreedomBox. This can avoid the need to create separate accounts in the htaccess file.

<Location /folder>
    Include includes/freedombox-auth-ldap.conf
    Require valid-user
</Location>
2 Likes

@sunil Wow, that’s great! I didn’t know, thanks!

Does this LDAP auth allow some kind of authorization, e. g. roles? Or would it just mean “any user that can authenticate” against my FB?

Authorization can be done as follows:

<Location ...>
    ...
    Require ldap-group cn=admin,ou=groups,dc=thisbox
    Require ldap-group cn=bit-torrent,ou=groups,dc=thisbox
</Location>

To require either admin or bit-torrent group. See full list of groups in User → Edit page.

2 Likes