Outils pour utilisateurs

Outils du site


issue175:tutoriel1

Ceci est une ancienne révision du document !


The Web Distributed Authoring and Versioning – styled as WebDAV in a curious combination of capitals – has come up several times in articles here on FullCircle Magazine. It can be seen as a fair example of the type of technology some of us old-timers like: simple, easy to work with, fast, and gets the job done with minimal stress. Let us go right on and say upfront that security is not a priority in this use-case. If you need security, you will lose convenience – and convenience is what today’s piece is all about. In its essence, WebDAV can be defined as using a simple web server and its associated HTTP protocol to share files across a network. Sharing files is an obvious necessity for most homes today, while doing so using web-based services over the Internet seems a tad overkill just to get a bit of data from one room to the next. Also, WebDAV has quite a bit of support from many desktop applications in the Ubuntu ecosystem, which is something I will get into a bit later, after actually setting up the server. For the time being, let us just state that our goals will be simple file sharing at user level, as in accessing files from any device on the network, editing text files on a shared volume, or making quick backups of data we need to share between computers.

The following community tutorial at https://www.digitalocean.com/community/tutorials/how-to-configure-webdav-access-with-apache-on-ubuntu-18-04 is a good place to start. I essentially followed their instructions, with some tweaks. Start out by installing the Apache server, if it is not already on your system. For instance: sudo apt update sudo apt install apache2 At this point, you can check your web server is already working by pointing a browser to the address http://localhost. You could also access it from another device on your network by using the server’s IP address. In my case, the desktop computer I am using has a local network address 192.168.1.104, so I typed in: http://192.168.1.104 .You should see the server’s default page (shown below).

For our purposes, we will leave this default web page be. If you are interested, the files are in the directory /var/www/html. Let us set up another directory to serve as our WebDAV share. We will also make this directory writable by the web-server’s user, so it can write files to it: sudo mkdir /var/www/webdav sudo chown www-data:www-data /var/www/webdav Now, edit the Apache configuration file /etc/apache2/sites-enabled/000-default.conf and add the following lines at the end. They make this share available at address http://localhost/webdav, and turn WebDAV access on: Alias /webdav /var/www/webdav <Directory /var/www/webdav> DAV On </Directory>

You will need to do this as administrator, so perhaps: sudo editor /etc/apache2/sites-enabled/000-default.conf That is about it. If we restart our Apache server, we can now browse our new WebDAV share in a web browser, using either the local address http://localhost/webdav on the server itself, or its IP address from another device: http:<your-IP-address>/webdav . However, a web browser such as Firefox or Chrome can only read data from our share, not write or modify files. This is already useful, specifically to share files from our computer to any device on our network. Just copy them to the directory /var/www/webdav, and they will appear for any device that has a web browser in it. Now, what about adding files from a file manager? I tried this out using Ubuntu 21.04’s Gnome nautilus file manager. We will need to know the key combination to type in an address: <Control> + L. Then, just put in our WebDAV address and the directory contents will show up (shown above). Yours will probably be empty to begin with; to populate it just add files by dragging them from any other folder. In many ways, this is a lot like using a USB stick to store files. You can erase files (please be careful, they really are wiped out with no warning!), rename files, create directories and subdirectories, and move files around just as with any other local disk (shown bottom left). If you find yourself using this WebDAV share regularly, it may be a good idea to bookmark it in the file browser, using a right mouse-click. As you can see, I used this very same setup to prepare the article, so you could say I eat my own dog food. What did come out useful was the possibility of editing files directly from the WebDAV share, both on the server itself and from another computer on the local network. Many programs in Ubuntu and its derivatives are aware of these shares, and can use them. For instance, I was able to open a file directly from the WebDAV share using LibreOffice’s standard Open dialog, and save it back both using the Save and Save as dialogs. When LibreOffice is editing a remote file, this is indicated in the window title bar. Since remote editing a file is not completely safe, it is always best to have a backup copy just in case. I did suffer an unforeseen electrical problem during which the desktop that serves as a server did not have a UPS and went down. When the lights came back on, the computer just powered back up, and the battery-powered laptop on which I had been doing the actual editing on was able to use LibreOffice’s default recuperation mechanism to restore the file to the point when power had been cut off at, and carry on. So, it must be said that the DAV system is sufficiently robust that it may very well be used for remote edition in many cases. Just make regular copies with different file names from time to time if editing a long document, especially if your local network has its glitches. Having a shortcut in the file manager also simplified access from within programs, since in most modern applications, the file manager’s entire left panel, with its tree view, is available in the program’s Open dialog. I also edited the screen captures by invoking Gimp from the WebDAV share with the right mouse click, with no problems to report. Now, there are some caveats we need to talk about. In the first place, seasoned users or administrators are probably yelling at their screens about not having any security at all in place. They are quite right about that. At the very minimum, setting up a password protection for your WebDAV share is a good idea. The tutorial referenced above has the instructions to do so. Additionally, perhaps using HTTPs instead of HTTP would be a plus, if any data needed to pass through an externally-visible network. This can also be done with Apache, though you will need a server certificate. Some technical know-how on web server management can be of help, so this would probably be outside the comfort zone of most casual home users. Now, whether just a simple password-based scheme is sufficient security for your uses, or even if it is at all necessary, is up to you. Personally, if I have a file containing sensitive data, I will probably be encrypting that file using any of the tools available on a Linux system, even when it is in situ on my hard drive. Just a hint: a password can be used when creating a ZIP file, and many other compressed file formats for that matter. Linux Mint’s nemo file application has the option: just right-click on the file to compress, and is it down there among the “Other Options”. Unfortunately, I cannot find this feature in Gnome’s current nautilus file manager anymore. A second point is that concurrent access by two users to the same file in the WebDAV shared folder is not a good idea. This file sharing system is not safe in that sense. So, if two or more people are accessing the same file, and modifying or writing to it, set up a system to make sure you do not overwrite each other’s work accidentally. Using different filenames is an easy solution. Finally, please remember a WebDAV is not, in itself, a backup solution. It may become one only if you have a second copy of each file on another computer and hard drive, e.g. one on the DAV share on a desktop, and a second in a local directory on a laptop. As usual, if you have less than three distinct copies of each file, you run the risk of losing a disk and some of your data. But WebDAV does make it easier for the end user to make copies of files on another computer. So, even though I do stress WebDAV is not a backup in itself, it may have a role to play in making backups easier on the user, and so more likely to happen in real life. Perhaps, this is a point to consider carefully. Finally, to sum up, let us have a bit of a gallery of devices accessing a WebDAV share. This first one is using KDE Plasma’s dolphin file manager. In this case, for some reason we need to use the address webdav:<your-IP-address>/webdav: We can also change our platform completely, and use Apple’s Mac OS. Here, the address is simply http:<your-IP-address>/webdav . We can use it either inside Safari, or inside the finder (file navigator). In the first case, files will be accessible but cannot be written, but in the finder, the shared directory appears on the desktop as any other mounted unit and can be used in the same way: Just as in Gnome, Cinnamon or KDE, once the shared directory is bookmarked in the finder in Mac OS, applications can access it directly – which facilitates opening or saving files. I find this consistency between Linux and Apple desktop behaviors rather pleasing. It can also be quite practical to do some work on a file in one system, then continue on another computer with different characteristics and software, if needed. This trick can also come in handy in households with a varied set of computers and users. As for handheld devices such as phones or tablets, as stated, read access to the share is easy from within the web browser. We can download files from the share to the device, which covers the activities most of us do, such as reading PDF files or watching videos on the device. Things can get a bit more involved if we want to transfer data in the opposite direction. Apple’s ecosystem is, as usual, a good showcase of what can happen when a single company controls the operating system entirely – the contrary of what we are used to in the open source community. The case in point is the Files app in iOS (Apple’s tablet OS) which used to be able to connect natively and write to WebDAV shares; recent versions have removed this option (from Files but also from Pages), which does seem a bit of a pity. There is some official guidance in this article from Apple Support: https://support.apple.com/en-us/HT210932. However, there are plenty of alternatives available in the App store. The situation is similar on Android devices, with a further difficulty regarding the large number of versions of this operating system that are in active use. So, to be clear going forward, just what can and cannot WebDAV do for us? What it can do is provide a simple and easy to set up a file share on our local network. This can be very convenient as a temporary storage to share files between computers, or between users, even working with different operating systems. Users can open and edit files directly from the shared directory. WebDAV can also make files available to mobile devices without needing to upload to and download from the Internet. What would be more complex to set up is true security, though this may not be an issue on a home network that is correctly firewalled off from the Internet… and to which the neighbors do not have WiFi access. What it cannot do well is to replace completely web-based services, specifically those which allow us to send files from a mobile device to our computer. In this case, it is probably more convenient for most users to continue using cloud storage or even email to send files over, or even a simple Bluetooth connection for small files. In a future article, I will be further exploring the applications of this technology to share calendars (CalDAV) or contact information (CardDAV). **

issue175/tutoriel1.1638294886.txt.gz · Dernière modification : 2021/11/30 18:54 de d52fr