webdav
A simple and standalone WebDAV server.
Install
For a manual install, please refer to the releases page and download the correct binary for your system. Alternatively, you can build or install it from source using the Go toolchain. You can either clone the repository and execute go build
, or directly install it, using:
1 | go install github.com/hacdias/webdav/v5@latest |
Docker
Docker images are provided on both GitHub’s registry and Docker Hub. You can pull the images using one of the following two commands. Note that this commands pull the latest released version. You can use specific tags to pin specific versions, or use main
for the development branch.
1 | # GitHub Registry |
Usage
For usage information regarding the CLI, run webdav --help
.
Docker
To use with Docker, you need to provide a configuration file and mount the data directories. For example, let’s take the following configuration file that simply sets the port to 6060
and the directory to /data
.
1 | port: 6060 |
You can now run with the following Docker command, where you mount the configuration file inside the container, and the data directory too, as well as forwarding the port 6060. You will need to change this to match your own configuration.
1 | docker run \ |
If you are using fail2ban, it would be helpful to add the parameters listed below. They will assist in analyzing the log.
1 | --log-driver journald \ |
Configuration
The configuration can be provided as a YAML, JSON or TOML file. Below is an example of a YAML configuration file with all the options available, as well as what they mean.
1 | address: 0.0.0.0 |
CORS
The allowed_*
properties are optional, the default value for each of them will be *
. exposed_headers
is optional as well, but is not set if not defined. Setting credentials
to true
will allow you to:
- Use
withCredentials = true
in javascript. - Use the
username:password@host
syntax.
Caveats
Reverse Proxy Service
When using a reverse proxy implementation, like Caddy, Nginx, or Apache, note that you need to forward the correct headers in order to avoid 502 errors. Here’s a Nginx configuration example:
1 | location / { |
Examples
Systemd
Example configuration of a systemd
service:
1 | [Unit] |
Fail2Ban Setup
To add security against brute-force attacks in your WebDAV server, you can configure Fail2Ban to ban IP addresses after a set number of failed login attempts.
Filter Configuration
Create a new filter rule under filter.d/webdav.conf
:
1 | [INCLUDES] |
This configuration will capture invalid login attempts and extract the IP address to ban.
Jail Configuration
In jail.d/webdav.conf
, define the jail that monitors your WebDAV log for failed login attempts:
1 | [webdav] |
- Replace
[your_port]
with the port your WebDAV server is running on. - Replace
[your_log_path]
with the path to your WebDAV log file.
If you use it with Docker and --log-driver journald
, replace logpath
with journalmatch = CONTAINER_NAME=[your_container_name]
Final Steps
Restart Fail2Ban to apply these configurations:
1
sudo systemctl restart fail2ban
Verify that Fail2Ban is running and monitoring your WebDAV logs:
1
sudo fail2ban-client status webdav
With this setup, Fail2Ban will automatically block IP addresses that exceed the allowed number of failed login attempts.
Contributing
Feel free to open an issue or a pull request.