WebDAV Server - Quick Start Guide
Get your WebDAV server up and running in 5 minutes!
🚀 Instant Setup
Option 1: Automated Installation (Recommended)
# Download and run the setup script
chmod +x setup.sh
./setup.sh
The script will:
- ✅ Check system requirements
- ✅ Install dependencies
- ✅ Create virtual environment
- ✅ Set up configuration
- ✅ Initialize database
- ✅ Create default admin user
Option 2: Manual Installation
# 1. Create project directory
mkdir webdav-server && cd webdav-server
# 2. Create virtual environment
python3 -m venv venv
source venv/bin/activate
# 3. Install dependencies
pip install aiohttp aiofiles aiohttp-session cryptography python-dotenv lxml gunicorn
# 4. Copy the main.py file from the artifacts
# 5. Create .env file
cat > .env << 'EOF'
HOST=0.0.0.0
PORT=8080
DB_PATH=./webdav.db
WEBDAV_ROOT=./webdav
AUTH_METHODS=basic,digest
JWT_SECRET_KEY=$(python -c "import secrets; print(secrets.token_hex(32))")
SESSION_TIMEOUT=3600
EOF
# 6. Create directory structure
mkdir -p webdav/users logs backups
# 7. Run the server
python main.py
Option 3: Docker (Fastest)
# 1. Create docker-compose.yml and Dockerfile from artifacts
# 2. Start with Docker Compose
docker-compose up -d
# 3. Check logs
docker-compose logs -f webdav
🎯 First Steps
1. Access the Server
Default Credentials:
- Username:
admin - Password:
admin123 - URL:
http://localhost:8080/
⚠️ IMPORTANT: Change the default password immediately!
2. Connect with Windows Explorer
Method 1: Map Network Drive
- Open File Explorer
- Right-click "This PC" → "Map network drive"
- Enter:
http://localhost:8080/ - Enter credentials:
admin/admin123
Method 2: Add Network Location
- Right-click "This PC" → "Add a network location"
- Choose custom network location
- Enter:
http://localhost:8080/ - Enter credentials when prompted
Windows Troubleshooting:
- If connection fails, restart WebClient service:
net stop webclient net start webclient
3. Connect with macOS Finder
- Press
Cmd+K(Go → Connect to Server) - Enter:
http://localhost:8080/ - Click "Connect"
- Enter credentials:
admin/admin123
4. Connect with Linux
# Install davfs2
sudo apt-get install davfs2
# Mount WebDAV share
sudo mount -t davfs http://localhost:8080/ /mnt/webdav
# Enter credentials when prompted
👥 User Management
Create Users via CLI
# Activate virtual environment
source venv/bin/activate
# Create a new user (interactive)
python webdav_cli.py user create john
# Create with all details
python webdav_cli.py user create jane \
--email jane@example.com \
--role user
# List all users
python webdav_cli.py user list
# Change password
python webdav_cli.py user password john
# Deactivate user
python webdav_cli.py user deactivate john
# Delete user
python webdav_cli.py user delete john --force
Create Users Programmatically
import asyncio
from main import Database
async def create_user():
db = Database('./webdav.db')
user_id = await db.create_user(
username='john',
password='SecurePass123!',
email='john@example.com',
role='user'
)
print(f"Created user ID: {user_id}")
asyncio.run(create_user())
🔧 Common Operations
Upload Files
Using curl:
curl -u admin:admin123 -T myfile.txt http://localhost:8080/myfile.txt
Using Python:
import requests
with open('myfile.txt', 'rb') as f:
response = requests.put(
'http://localhost:8080/myfile.txt',
data=f,
auth=('admin', 'admin123')
)
print(response.status_code)
Download Files
curl -u admin:admin123 http://localhost:8080/myfile.txt -o downloaded.txt
Create Directories
curl -u admin:admin123 -X MKCOL http://localhost:8080/newfolder/
List Directory Contents
curl -u admin:admin123 -X PROPFIND http://localhost:8080/ \
-H "Depth: 1" \
-H "Content-Type: application/xml" \
--data '<?xml version="1.0"?><D:propfind xmlns:D="DAV:"><D:allprop/></D:propfind>'
Copy Files
curl -u admin:admin123 -X COPY \
http://localhost:8080/source.txt \
-H "Destination: http://localhost:8080/destination.txt"
Move Files
curl -u admin:admin123 -X MOVE \
http://localhost:8080/old.txt \
-H "Destination: http://localhost:8080/new.txt"
Delete Files
curl -u admin:admin123 -X DELETE http://localhost:8080/myfile.txt
🔒 Security Setup
Change Default Password
python webdav_cli.py user password admin
# Enter new password when prompted
Enable HTTPS (Production)
- Get SSL Certificate (Let's Encrypt):
sudo certbot certonly --standalone -d webdav.example.com
- Update .env:
SSL_ENABLED=true
SSL_CERT_PATH=/etc/letsencrypt/live/webdav.example.com/fullchain.pem
SSL_KEY_PATH=/etc/letsencrypt/live/webdav.example.com/privkey.pem
- Restart server
Use Nginx Reverse Proxy (Recommended)
- Install Nginx:
sudo apt-get install nginx
-
Copy nginx.conf from artifacts to
/etc/nginx/conf.d/webdav.conf -
Update domain name in config
-
Reload Nginx:
sudo nginx -t
sudo systemctl reload nginx
📊 Monitoring
View Statistics
python webdav_cli.py stats
Check Active Locks
python webdav_cli.py lock list
View Logs
# Application logs
tail -f logs/webdav.log
# Access logs
tail -f logs/access.log
# If using systemd
sudo journalctl -u webdav -f
🐳 Docker Deployment
Start Service
docker-compose up -d
View Logs
docker-compose logs -f
Stop Service
docker-compose down
Update and Restart
docker-compose pull
docker-compose up -d --build
Backup Data
# Backup database
docker exec webdav-server python webdav_cli.py backup
# Backup files
docker cp webdav-server:/app/webdav ./backup-webdav/
⚙️ Production Deployment
Using Gunicorn (Recommended)
# Start with Gunicorn
gunicorn main:init_app \
--config gunicorn_config.py \
--bind 0.0.0.0:8080 \
--workers 4
# With systemd (after setup)
sudo systemctl enable webdav
sudo systemctl start webdav
sudo systemctl status webdav
Environment Configuration
Development:
DEBUG=true
LOG_LEVEL=DEBUG
WORKERS=1
Production:
DEBUG=false
LOG_LEVEL=INFO
WORKERS=4
SSL_ENABLED=true
RATE_LIMIT_ENABLED=true
🔥 Common Issues
Issue: Connection Refused
Solution:
# Check if server is running
ps aux | grep python
# Check port
sudo netstat -tlnp | grep 8080
# Check firewall
sudo ufw allow 8080/tcp
Issue: Permission Denied
Solution:
# Fix directory permissions
chmod -R 755 webdav/
chown -R $USER:$USER webdav/
Issue: Database Locked
Solution:
# Stop all instances
pkill -f "python main.py"
# Check for locks
lsof webdav.db
# Restart server
python main.py
Issue: Windows Explorer Won't Connect
Solutions:
- Restart WebClient service
- Enable Basic Auth in registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\WebClient\Parameters BasicAuthLevel = 2 - Use HTTPS instead of HTTP
- Ensure URL ends with
/
📚 Next Steps
- Read the full README.md for comprehensive documentation
- Configure SSL/TLS for production use
- Set up automated backups
- Configure monitoring and alerts
- Review security settings
- Set up user quotas and permissions
- Configure rate limiting
- Enable caching with Redis
🆘 Getting Help
- Documentation: Check README.md and inline comments
- Logs: Always check logs first (
logs/webdav.log) - CLI Help:
python webdav_cli.py --help - Test Connection:
curl -v http://localhost:8080/
🎉 You're All Set!
Your WebDAV server is now ready to use. Start by:
- Changing the default admin password
- Creating user accounts
- Connecting with your favorite WebDAV client
- Uploading some files
Happy file sharing! 🚀