Zotero

2014/12/09 zotero webdav nginx apache

Zotero is an Open Source tool that lets you organise your bibliography, syncing it with the cloud. Unlike other alternatives such as Mendeley, Zotero can upload the attachments and data to a private cloud via WebDav.

If you use nginx as your web server, know that even though it provides partial support for webdav, Zotero needs more than that. Hence, you will need another webdav server, and optionally let nginx proxy to it. This short post provides the basics to get that set-up working under Debian/Ubuntu.

Setting up Apache

First we need to install Apache:

1
sudo apt-get install apache2

Change the head of “/etc/apache2/sites-enabled/000-default” to:

1
<VirtualHost *:880>

Then, create a file /etc/apache2/sites-available/webdav:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Alias /dav /home/webdav/dav
<Location /dav>
    Dav on
    Order Allow,Deny
    Allow from all
    Dav On
    Options +Indexes
    AuthType Basic
    AuthName DAV
    AuthBasicProvider file
    AuthUserFile /home/webdav/.htpasswd
    Require valid-user
</Location>

Ideally, you want your webdav folders to be private, adding authentication to them. So you need to create the webdav and zotero users and add the passwords to an htpasswd file. Even though you could use a single user, since you will be configuring several clients with your credentials I encourage you to create the zotero user as well. This way you can always change the password for zotero without affecting any other application using webdav.

1
2
3
4
sudo adduser webdav
sudo htpasswd -c /home/webdav/.htpasswd webdav
sudo htpasswd /home/webdav/.htpasswd zotero
sudo mkdir -p /home/webdav/dav/zotero

Enable the site and restart apache:

1
2
3
4
sudo a2enmod webdav
sudo a2enmod dav_fs
sudo a2ensite webdav
sudo service apache2 restart

At this point everything should be working at http://<your_host>:880/dav/zotero

Setting up NGINX

After the Apache side is working, we can use nginx as a proxy to get cleaner URIs. In your desired site/location, add this:

1
2
3
4
5
6
7
location /dav {
    client_max_body_size 20M;
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_pass http://127.0.0.1:880;
}

Now just reload nginx:

1
sudo service nginx force-reload

Extras