webdav setup
Today I want to setup the webdav service on my self-host server to be able sync the omniFocus data among my apple devices. I've already the default installed nginx service up on the server, the webdav modules are needed, and nginx-extras
package contains the mod-http-dav-ext
module,
$ apt install nginx-extras
Now some configurations:
Create the data stored folders:
$ sudo mkdir /var/html/webdav
$ sudo chown www-datad /var/html/webdav
Create the webdev.memodir.cn.conf in /etc/nginx/site-available
$ sudo vim /etc/nginx/site-available/webdev.memodir.cn.conf
add the following configs:
server {
server_name dav.memodir.cn;
root /var/www/webdav;
auth_basic realm_name;
auth_basic_user_file /var/webdav/auth/.passwords.list;
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw all:rw;
autoindex on;
}
Now you need to setup the authentication users by following command:
$ echo -n 'Your-User-Name:' | sudo tee /var/webdav/auth/.passwords.list
$ openssl passwd -apr1 | sudo tee -a /var/webdav/auth/.passwords.list
Password:
If you need adding other users to this file, you need to add the -a
after the tee, like:
$ echo -n 'Another-User-Name:' | sudo tee -a /var/webdav/auth/.passwords.list
Now the configuration is ready, try to restart the nginx server:
$ sudo service nginx restart
The service is alive but it's running on the plain http protocal, we can use Let'sEncrypt to setup the ssl easily:
Add Certbot PPA and install the Certbot
$ sudo add-apt-repository universe
$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt-get update
$ sudo apt-get install certbot python3-certbot-nginx
Install the certifications:
$ sudo certbot --nginx
Now you can access via https.
It's done, enjoy your webdav service.