├── Dockerfile ├── LICENSE ├── README.md ├── docker-compose.yml ├── entrypoint.sh └── webdav.conf /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:trusty 2 | 3 | RUN apt-get update && apt-get install -y nginx nginx-extras apache2-utils 4 | 5 | VOLUME /media 6 | EXPOSE 80 7 | COPY webdav.conf /etc/nginx/conf.d/default.conf 8 | RUN rm /etc/nginx/sites-enabled/* 9 | 10 | COPY entrypoint.sh / 11 | RUN chmod +x entrypoint.sh 12 | CMD /entrypoint.sh && nginx -g "daemon off;" 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Alexander Gorokhov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Supported tags and respective `Dockerfile` links 2 | 3 | - [`latest` (*Dockerfile*)](https://github.com/sashgorokhov/docker-nginx-webdav/blob/master/Dockerfile) 4 | 5 | [![](https://badge.imagelayers.io/sashgorokhov/webdav:latest.svg)](https://imagelayers.io/?images=sashgorokhov/webdav:latest 'Get your own badge on imagelayers.io') 6 | 7 | # How to use this image 8 | 9 | ```console 10 | $ docker run --name webdav -p 80:80 -v /media:/media -d sashgorokhov/webdav 11 | ``` 12 | This will start a webdav server listening on the default port of 80. 13 | Then access it via `http://localhost:80` or `http://host:80` in a browser. 14 | 15 | This server will serve files located in your /media folder 16 | 17 | Image's supported volumes: 18 | - `/media` - served directory 19 | 20 | To restrict access to only authorized users, you can define two environment variables: `USERNAME` and `PASSWORD` 21 | ```console 22 | $ docker run --name webdav -p 80:80 -v /media:/media -e USERNAME=webdav -e PASSWORD=webdav -d sashgorokhov/webdav 23 | ``` 24 | 25 | # Supported Docker versions 26 | 27 | This image is officially supported on Docker version 1.10.2. 28 | Support for older versions (down to 1.6) is provided on a best-effort basis. 29 | Please see [the Docker installation documentation](https://docs.docker.com/installation/) for details on how to upgrade your Docker daemon. 30 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | webdav: 4 | build: . 5 | ports: 6 | - "80:80" 7 | volumes: 8 | - "/mnt:/media" 9 | environment: 10 | USERNAME: user 11 | PASSWORD: passwd -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [[ -n "$USERNAME" ]] && [[ -n "$PASSWORD" ]] 4 | then 5 | htpasswd -bc /etc/nginx/htpasswd $USERNAME $PASSWORD 6 | echo Done. 7 | else 8 | echo Using no auth. 9 | sed -i 's%auth_basic "Restricted";% %g' /etc/nginx/conf.d/default.conf 10 | sed -i 's%auth_basic_user_file htpasswd;% %g' /etc/nginx/conf.d/default.conf 11 | fi -------------------------------------------------------------------------------- /webdav.conf: -------------------------------------------------------------------------------- 1 | 2 | server { 3 | listen 80; 4 | 5 | access_log /dev/stdout; 6 | error_log /dev/stdout info; 7 | 8 | client_max_body_size 0; 9 | 10 | location / { 11 | create_full_put_path on; 12 | autoindex on; 13 | autoindex_exact_size off; 14 | autoindex_localtime on; 15 | charset utf-8; 16 | 17 | dav_methods PUT DELETE MKCOL COPY MOVE; 18 | dav_ext_methods PROPFIND OPTIONS; 19 | dav_access user:rw group:rw all:rw; 20 | 21 | auth_basic "Restricted"; 22 | auth_basic_user_file /etc/nginx/htpasswd; 23 | 24 | root /media/; 25 | } 26 | } --------------------------------------------------------------------------------