Apache
Running WebDav in container
Commands
docker build -t webdav .
then run: docker run -it -p 81:80 -v /host/path/:/var/www/webdav/hass:rw -e HTUSER=user -e HTPASS=password --name webdav webdav
Dockerfile
FROM debian:latest
RUN apt-get update && apt-get install apache2 -y
COPY configure.sh /usr/local/bin/configure.sh
RUN chmod +x /usr/local/bin/configure.sh && /usr/local/bin/configure.sh
EXPOSE 80/tcp
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
USER www-data:www-data
CMD ["/usr/local/bin/entrypoint.sh"]Configure script
#!/bin/bash
cd /etc/apache2/sites-available/
cat << EOT > webdav.local.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
Servername webdav.local
DocumentRoot /var/www/webdav
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/webdav/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Alias /hass /var/www/webdav/hass
<Location /hass>
DAV On
# AuthType Digest
AuthType Basic
AuthName "webdav"
AuthUserFile /usr/local/apache2/conf/.htpasswd
Require valid-user
</Location>
</VirtualHost>
EOT
mkdir /var/www/webdav
sh -c 'echo "Welcome to WEBDAV" > /var/www/webdav/index.html'
chown www-data:www-data /var/www/webdav
a2enmod dav_fs
# a2enmod auth_digest
mkdir /var/www/webdav/hass
chown www-data:www-data /var/www/webdav/hass
a2dissite 000-default
a2ensite webdav.local
mkdir -p /usr/local/apache2/conf/
chown -R www-data:www-data /usr/local/apache2
mkdir -p /var/run/apache2
chown -R www-data:www-data /var/run/apache2
chown -R root:www-data /var/log/apache2
chmod 650 /var/log/apache2
chmod -R 620 /var/log/apache2/*
# Update log rotate to maintain the right permission
sed -i 's/create 640 root adm/create 620 root www-data/' /etc/logrotate.d/apache2Entrypoint Script
Reference
Last updated