Simple private cloud storage using WebDAV

WebDAV stand for the Web Distributed Authoring and Versioning.
For the end user it means file and diroctory manipulation in URL namespace. Operating systems with GUI are able to handle WebDAV resource as remote device.

Why this storage type is called cloud storage? Install this http server setup on 2 or more separate machine on different network and synchronize the data via network. I’ll use ZFS snapshots and the incremental send/receive capability of ZFS.

I’m going to use the FreeBSD Ports Collection to compile the nginx webserver.

portsnap fetch update
cd /usr/ports/www/nginx
make config

Keep in mind we need the http_dav_module of nginx. The http_ssl_module will be compiled also:

nginx make config menu

make install clean

Compile perl compatible regexp package is an obligate dependency:

pcre config "popup"

After a few minutes:

Add the following line to the /etc/rc.conf:


Test nginx works well:

# /usr/local/etc/rc.d/nginx start
Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.
# ps aux|grep ngin
root     50847   0.0  0.1  22880   3200  ??  IsJ   2:12PM 0:00.00 nginx: master
www      50848   0.0  0.1  22880   3640  ??  IJ    2:12PM 0:00.00 nginx: worker
root     50850   0.0  0.0  16424   1224   4  S+J   2:12PM 0:00.00 grep ngin

Test from browser:

nginx works

Install replacement of Apache htpasswd as package (python will be installed as dependency):

pkg_add -rv py27-htpasswd

It works only in batch mode and tries to use the python interpreter at wrong path. Use this form first time. Without -c second time:

python /usr/local/bin/ -c -b /usr/local/etc/nginx/htpasswd tcso useanotherpasshere

And the nginx.conf:

worker_processes  1;

events {
worker_connections  1024;

http {
include       mime.types;
default_type  application/octet-stream;
sendfile        on;
keepalive_timeout  65;
server {
server_name  localhost;

location / {
root                        /usr/local/www/dav;
auth_basic                  “Restricted for authorized users!”;
auth_basic_user_file        /usr/local/etc/nginx/htpasswd;
client_body_temp_path       /usr/local/www/dav_client_temp;
dav_methods                 PUT DELETE MKCOL COPY MOVE;
create_full_put_path        on;
dav_access                  user:rw  group:rw  all:r;

# redirect server error pages to the static page /50x.html
error_page   500 502 503 504  /50x.html;
location = /50x.html {
root   /usr/local/www/nginx-dist;


The client side:


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s