Here is a step-by-step guide to help you set up a WebDAV server using Docker and provide user access to store data.
-
Install Docker on your system: Follow the official Docker installation guide for your operating system: https://docs.docker.com/get-docker/
-
Pull the WebDAV server image: Use the following command to pull the WebDAV server image from Docker Hub:
docker pull nextcloud:latest -
Run the WebDAV server container: Use the following command to run the WebDAV server container, replacing
<data-directory>with the desired directory path for your data:docker run -d -p 80:80 -p 443:443 -v <data-directory>:/var/www/html nextcloud -
Configure Nginx to proxy requests to the WebDAV server: Install Nginx on your system if you haven't already:
sudo apt-get install nginxCreate a new Nginx configuration file at
/etc/nginx/sites-available/webdav:server { listen 80; server_name your_domain_or_IP; location / { proxy_pass http://localhost:80; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }Enable the new configuration file and disable the default Nginx configuration:
sudo ln -s /etc/nginx/sites-available/webdav /etc/nginx/sites-enabled/ sudo systemctl reload nginx -
Set up a user for WebDAV access: Add a new user and group for WebDAV access:
sudo useradd -r webdav sudo groupadd webdavChange the ownership of the data directory to the new user and group:
sudo chown -R webdav:webdav <data-directory> -
Modify the Nextcloud configuration to use the new user and group: Access the WebDAV server container using the following command:
docker exec -it <container-id> php /var/www/html/occ config:system:trust_host_verification false docker exec -it <container-id> php /var/www/html/occ config:system:verify_peer false docker exec -it <container-id> php /var/www/html/occ config:app:set --setting=overwrite_local_config --value=true docker exec -it <container-id> php /var/www/html/occ config:system:set trusted_domains --value="your_domain_or_IP" docker exec -it <container-id> php /var/www/html/occ config:system:set file_scan_chunk_size --value=10485760 docker exec -it <container-id> php /var/www/html/occ user:create webdav --password=<password> [email protected] --name=WebDAV --uid=33 --gid=33 docker exec -it <container-id> php /var/www/html/occ db:user:setadmin webdavReplace
<container-id>with the ID of your WebDAV server container and<password>with a secure password for the WebDAV user. -
Test the WebDAV server: Access your WebDAV server using a WebDAV client, such as Cyberduck, and use the
webdavuser and password you created.
References:
- Nextcloud Docker documentation: https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/docker.html
- Nginx proxy configuration: https://www.nginx.com/resources/wiki/start/top/tutorials/config_nginx/reverse_proxy/
- Docker installation: https://docs.docker.com/get-docker/
- Creating a new user and group: https://www.digitalocean.com/community/tutorials/how-to-create-users-with-ssh-keys-on-ubuntu-18-04-core
- Setting ownership of files and directories: https://www.digitalocean.com/community/tutorials/how-to-set-file-permissions-with-chmod-on-ubuntu-18-04
- Nextcloud configuration commands: https://docs.nextcloud.com/server/latest/admin_manual/configuration_command_line/index.html