Information Technology Grimoire

Version .0.0.1

IT Notes from various projects because I forget, and hopefully they help you too.

webdav

WebDav Apache Config

<VirtualHost *:443>
  ServerName your.dav.server.com
  DocumentRoot "/var/webdav/files"
  ErrorLog logs/ssl_error_log_dav
  TransferLog logs/ssl_access_log_dav
  CustomLog logs/ssl_request_log_dav "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"

  SSLEngine on
  SSLCipherSuite AES256+EECDH:AES256+EDH
  SSLProtocol All -SSLv2 -SSLv3
  SSLHonorCipherOrder On
  SSLCompression off
  SSLCertificateFile /etc/letsencrypt/live/your.dav.server/cert.pem
  SSLCertificateKeyFile /etc/letsencrypt/live/your.dav.server/privkey.pem
  SSLCertificateChainFile /etc/letsencrypt/live/your.dav.server/chain.pem

  <Location />
    Require valid-user
    AuthType "Basic"
    AuthName "Oh no you didn't"
    AuthBasicProvider file
    AuthUserFile /var/webdav/.htpasswd
    Dav On
  </Location>
</VirtualHost>

Files/Passwords

mkdir -p /var/webdav/files
semanage fcontext --add  -t httpd_sys_rw_content_t '/var/webdav/files(/.*)?'
systemctl enable --now httpd
htpasswd -c5 /var/webdav/.htpasswd myuser

Allows for File Locking and Multiple use Allows for “drive like” mapping Uses Port 80/443 as it is a web extension two factor is possible

WebDav Verbs

It is a good idea to get familiar with WebDAV. Here are the new methods WebDAV adds to HTTP 1.1, according to Wikipedia:

  • PROPFIND: Used to retrieve properties, persisted as XML, from a resource. It is also overloaded to allow one to retrieve the collection structure (a.k.a. directory hierarchy) of a remote system.
  • PROPPATCH: Used to change and delete multiple properties on a resource in a single atomic act.
  • MKCOL: Used to create collections (a.k.a. directory).
  • COPY: Used to copy a resource from one URI to another.
  • MOVE: Used to move a resource from one URI to another.
  • LOCK: Used to put a lock on a resource. WebDAV supports both shared and exclusive locks.
  • UNLOCK: To remove a lock from a resource.

Client

http://www.bitkinex.com/downloaded

Specify the folder/file not just the raw resource:

https://192.168.1.51:5006/NetBackup/joplin/info.json

Installation

Install apache2 server

sudo apt-get install -y apache2

Enable the WebDAV protocol support in apache2

(remember to execute in the user directory or report an error)

cd ~
sudo a2enmod dav
sudo a2enmod dav_fs

Create shared directory and modify permissions

sudo mkdir -p /var/www/webdav
sudo mkdir /var/www/webdav/USERNAME
sudo chown -R www-data:www-data  /var/www/webdav
sudo chown -R 750 /var/www/webdav

Create the access user database of WebDAV

create the user PI by the way

sudo htpasswd -c /etc/apache2/webdav.password pi

Create guest user

sudo htpasswd /etc/apache2/webdav.password guest

Modify user database access rights

sudo chown root:www-data /etc/apache2/webdav.password
sudo chmod 640 /etc/apache2/webdav.password

Open default profile

sudo vim /etc/apache2/sites-available/000-default.conf

Replace all with the following (remember to back up first):

Alias /webdav  /var/www/webdav

<Location /webdav>
 Options Indexes
 DAV On
 AuthType Basic
 AuthName "webdav"
 AuthUserFile /etc/apache2/webdav.password
 Require valid-user
 </Location>

Restart apache2 server

sudo systemctl restart apache2