Setup a WebDav fileserver
mouse 406 · person cloud · link
Last update
2017-11-03
2017
11-03
« — »
1
apt-get install nginx nginx-extras

Use webdav and fancyindex modules in your .conf file:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
server {
  listen 1234;
  server_name webdav;
  index  index.html index.htm;

  try_files  $uri  $uri/  =404;

  location /fancyindex.css {
    root /path/to/fancyindex_static_files;
  } # location

  location / {
    root /path/to/shared_folder;

    fancyindex            on;
    fancyindex_localtime  on;   # show file times as local time
    fancyindex_exact_size off;  # human-readable file sizes
    fancyindex_css_href   /fancyindex.css;

    dav_methods     PUT  DELETE  MKCOL  COPY  MOVE;
    dav_ext_methods PROPFIND  OPTIONS;

    min_delete_depth 3;                   # only remove files with path deeper than the specified number
    create_full_put_path  on;             # creating all needed intermediate directories
    dav_access  user:rw  group:r  all:r;  # sets access permissions for newly created files and directories
    client_max_body_size  0;              # file size limit for new files

    # directory holding temporary files (uploads with PUT)
    client_body_temp_path /path/to/webdav_tmp;
  }
} # server

and here is a sample fancyindex.css:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
h1 { font-size: 1rem; }

tr { height: 3rem; }

a[href$="/"] {
  font-weight:         bold;
  padding-left:        1.5rem;
  background-image:    url("data:image/svg+xml;base64,PHN2ZyB3aWR0aD0nMjAwJyBoZWlnaHQ9JzIwMCcgZmlsbD0iI0YzOEYxOSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgODAgNjIuNzciIHg9IjBweCIgeT0iMHB4Ij48dGl0bGU+Zm9sZGVyPC90aXRsZT48ZyBkYXRhLW5hbWU9IkNhbHF1ZSAyIj48Zz48cGF0aCBkPSJNNzMuMjcsMTEuMTJIMzQuNzFhMi41MSwyLjUxLDAsMCwxLTItMWwtNC45LTYuNzdBOCw4LDAsMCwwLDIxLjI5LDBINy4wOEE3LjA5LDcuMDksMCwwLDAsMCw3LjA4djQ4LjZhNy4wOSw3LjA5LDAsMCwwLDcuMDgsNy4wOEg3Mi45MkE3LjA5LDcuMDksMCwwLDAsODAsNTUuNjhWMTcuODVBNi43NCw2Ljc0LDAsMCwwLDczLjI3LDExLjEyWk03LjA4LDUuNTFIMjEuMjlhMi41MSwyLjUxLDAsMCwxLDIsMWw0LjksNi43N2E4LDgsMCwwLDAsNi40OSwzLjMxSDczLjI3YTEuMjMsMS4yMywwLDAsMSwxLjIyLDEuMjJ2Mi41NmgtNjlWNy4wOEExLjYsMS42LDAsMCwxLDcuMDgsNS41MVoiLz48L2c+PC9nPjwvc3ZnPg==");
  background-position: 0 0;
  background-size:     1rem 1rem;
  background-repeat:   no-repeat;
}

td a { text-decoration: none; }

Open it in Xfce thunar with:

1
thunar dav://localhost:1234/

On Android you can use the webdav plugin for total commander.


Source: william.j, starbeam, devianteng., nginx dav, nginx dav-ext, XFCE Thunar