├── Dockerfile ├── LICENSE ├── README.md ├── docker-compose-build.yml ├── docker-compose.yml ├── entrypoint.sh └── webdav.conf /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:10.6-slim 2 | 3 | LABEL maintainer "ugeek. ugeekpodcast@gmail.com" 4 | 5 | ARG UID=${UID:-1000} 6 | ARG GID=${GID:-1000} 7 | 8 | RUN apt-get update && \ 9 | apt-get install -y --no-install-recommends \ 10 | nginx \ 11 | nginx-extras \ 12 | apache2-utils && \ 13 | rm -rf /var/lib/apt/lists 14 | 15 | RUN usermod -u $UID www-data && groupmod -g $GID www-data 16 | 17 | VOLUME /media 18 | EXPOSE 80 19 | 20 | COPY webdav.conf /etc/nginx/conf.d/default.conf 21 | RUN rm /etc/nginx/sites-enabled/* 22 | 23 | COPY entrypoint.sh / 24 | RUN chmod +x entrypoint.sh 25 | 26 | CMD /entrypoint.sh && nginx -g "daemon off;" 27 | -------------------------------------------------------------------------------- /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 | # Servidor webdav partiendo de debian-testing 2 | 3 | ## Clonar el repositorio 4 | 5 | ``` 6 | git clone https://github.com/uGeek/docker-nginx-webdav.git 7 | ``` 8 | 9 | y accedemos al interior de la carpeta: 10 | 11 | ``` 12 | cd docker-nginx-webdav 13 | ``` 14 | 15 | ## Construir la imagen 16 | ``` 17 | docker build -t ugeek/webdav:arm . 18 | ``` 19 | 20 | ## Ver el número de imagen: 21 | ``` 22 | docker images 23 | ``` 24 | 25 | ## Montar el contenedor 26 | 27 | ### docker-cli 28 | USERNAME: webdav 29 | PASSWORD: webdav 30 | PUERTO: 80 31 | 32 | --restart=unless-stopped: Iniciar cada vez que iniciemos el servidor 33 | 34 | 35 | ``` 36 | docker run --name webdav \ 37 | --restart=unless-stopped \ 38 | -p 80:80 \ 39 | -v $HOME/docker/webdav:/media \ 40 | -e USERNAME=webdav \ 41 | -e PASSWORD=webdav \ 42 | -e TZ=Europe/Madrid \ 43 | -e UDI=1000 \ 44 | -e GID=1000 \ 45 | -d ugeek/webdab:arm 46 | ``` 47 | 48 | ### docker-compose con traefik y proxy inverso 49 | 50 | ``` 51 | version: '2' 52 | services: 53 | webdav: 54 | container_name: webdav 55 | image: ugeek/webdav:arm 56 | ports: 57 | - 80:80 58 | volumes: 59 | - $HOME/docker/webdav:/media 60 | environment: 61 | - USERNAME=webdav 62 | - PASSWORD=webdav 63 | - UID=1000 64 | - GID=1000 65 | - TZ=Europe/Madrid 66 | networks: 67 | - web 68 | labels: 69 | - traefik.backend=webdav 70 | - traefik.frontend.rule=Host:webdav.tu_dominio.duckdns.org 71 | - traefik.docker.network=web 72 | - traefik.port=80 73 | - traefik.enable=true 74 | # Adding in secure headers 75 | - traefik.http.middlewares.securedheaders.headers.forcestsheader=true 76 | - traefik.http.middlewares.securedheaders.headers.sslRedirect=true 77 | - traefik.http.middlewares.securedheaders.headers.STSPreload=true 78 | - traefik.http.middlewares.securedheaders.headers.ContentTypeNosniff=true 79 | - traefik.http.middlewares.securedheaders.headers.BrowserXssFilter=true 80 | - traefik.http.middlewares.securedheaders.headers.STSIncludeSubdomains=true 81 | - traefik.http.middlewares.securedheaders.headers.stsSeconds=63072000 82 | - traefik.http.middlewares.securedheaders.headers.frameDeny=true 83 | - traefik.http.middlewares.securedheaders.headers.browserXssFilter=true 84 | - traefik.http.middlewares.securedheaders.headers.contentTypeNosniff=true 85 | networks: 86 | web: 87 | external: true 88 | ``` 89 | 90 | Introduce el comando... 91 | ``` 92 | docker-compose up -d 93 | ``` 94 | 95 | 96 | ## Logs 97 | 98 | Añadido nuevo registro de logs. 99 | 100 | ### Ver logs 101 | 102 | ``` 103 | docker exec -it webdav cat /var/log/nginx/webdav_access.log 104 | ``` 105 | 106 | ### Logs en tiempo real 107 | 108 | ``` 109 | docker exec -it webdav cat /var/log/nginx/webdav_access.log 110 | ``` 111 | 112 | 113 | 114 | ### logs con error 115 | ``` 116 | docker exec -it webdav /var/log/nginx/webdav_error.log 117 | ``` 118 | 119 | ## Agradecimientos 120 | - Gracias a [Germán Martín](https://github.com/gmag11) por añadir la compatibilidad con clientes Windows 10. [Fork](https://github.com/gmag11/docker-webdav) 121 | 122 | 123 | -------------------------------------------------------------------------------- /docker-compose-build.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | webdav: 4 | container_name: webdav 5 | build: . 6 | ports: 7 | - "80:80" 8 | volumes: 9 | - "$HOME/docker/webdav:/media" 10 | environment: 11 | - USERNAME=webdav 12 | - PASSWORD=webdav 13 | - UID=1000 14 | - GID=1000 15 | - TZ=Europe/Madrid 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | webdav: 4 | container_name: webdav 5 | image: ugeek/webdav:arm 6 | ports: 7 | - 80:80 8 | volumes: 9 | - $HOME/docker/webdav:/media 10 | environment: 11 | - USERNAME=webdav 12 | - PASSWORD=webdav 13 | - UID=1000 14 | - GID=1000 15 | - TZ=Europe/Madrid 16 | networks: 17 | - web 18 | labels: 19 | - traefik.backend=webdav 20 | - traefik.frontend.rule=Host:webdav.tu_dominio.duckdns.org 21 | - traefik.docker.network=web 22 | - traefik.port=80 23 | - traefik.enable=true 24 | # Adding in secure headers 25 | - traefik.http.middlewares.securedheaders.headers.forcestsheader=true 26 | - traefik.http.middlewares.securedheaders.headers.sslRedirect=true 27 | - traefik.http.middlewares.securedheaders.headers.STSPreload=true 28 | - traefik.http.middlewares.securedheaders.headers.ContentTypeNosniff=true 29 | - traefik.http.middlewares.securedheaders.headers.BrowserXssFilter=true 30 | - traefik.http.middlewares.securedheaders.headers.STSIncludeSubdomains=true 31 | - traefik.http.middlewares.securedheaders.headers.stsSeconds=63072000 32 | - traefik.http.middlewares.securedheaders.headers.frameDeny=true 33 | - traefik.http.middlewares.securedheaders.headers.browserXssFilter=true 34 | - traefik.http.middlewares.securedheaders.headers.contentTypeNosniff=true 35 | networks: 36 | web: 37 | external: true 38 | -------------------------------------------------------------------------------- /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 12 | mediaowner=$(ls -ld /media | awk '{print $3}') 13 | echo "Current /media owner is $mediaowner" 14 | if [ "$mediaowner" != "www-data" ] 15 | then 16 | chown -R www-data:www-data /media 17 | fi 18 | -------------------------------------------------------------------------------- /webdav.conf: -------------------------------------------------------------------------------- 1 | dav_ext_lock_zone zone=a:10m; 2 | 3 | server { 4 | #server_name webdav.mashnp.sk; 5 | set $webdav_root "/media/"; 6 | auth_basic "Restricted"; 7 | auth_basic_user_file /etc/nginx/htpasswd; 8 | dav_ext_lock zone=a; 9 | 10 | location / { 11 | 12 | root $webdav_root; 13 | error_page 599 = @propfind_handler; 14 | error_page 598 = @delete_handler; 15 | error_page 597 = @copy_move_handler; 16 | open_file_cache off; 17 | 18 | access_log /var/log/nginx/webdav_access.log; 19 | error_log /var/log/nginx/webdav_error.log debug; 20 | 21 | send_timeout 3600; 22 | client_body_timeout 3600; 23 | keepalive_timeout 3600; 24 | lingering_timeout 3600; 25 | client_max_body_size 10G; 26 | 27 | if ($request_method = PROPFIND) { 28 | return 599; 29 | } 30 | 31 | if ($request_method = PROPPATCH) { # Unsupported, allways return OK. 32 | add_header Content-Type 'text/xml'; 33 | return 207 'HTTP/1.1 200 OK'; 34 | } 35 | 36 | if ($request_method = MKCOL) { # Microsoft specific handle: add trailing slash. 37 | rewrite ^(.*[^/])$ $1/ break; 38 | } 39 | 40 | if ($request_method = DELETE) { 41 | return 598; 42 | } 43 | 44 | if ($request_method = COPY) { 45 | return 597; 46 | } 47 | 48 | if ($request_method = MOVE) { 49 | return 597; 50 | } 51 | 52 | dav_methods PUT MKCOL; 53 | dav_ext_methods OPTIONS LOCK UNLOCK; 54 | create_full_put_path on; 55 | min_delete_depth 0; 56 | dav_access user:rw group:rw all:rw; 57 | 58 | autoindex on; 59 | autoindex_exact_size on; 60 | autoindex_localtime on; 61 | 62 | if ($request_method = OPTIONS) { 63 | add_header Allow 'OPTIONS, GET, HEAD, POST, PUT, MKCOL, MOVE, COPY, DELETE, PROPFIND, PROPPATCH, LOCK, UNLOCK'; 64 | add_header DAV '1, 2'; 65 | return 200; 66 | } 67 | } 68 | location @propfind_handler { 69 | internal; 70 | 71 | open_file_cache off; 72 | if (!-e $webdav_root/$uri) { # Microsoft specific handle. 73 | return 404; 74 | } 75 | root $webdav_root; 76 | dav_ext_methods PROPFIND; 77 | } 78 | location @delete_handler { 79 | internal; 80 | 81 | open_file_cache off; 82 | if (-d $webdav_root/$uri) { # Microsoft specific handle: Add trailing slash to dirs. 83 | rewrite ^(.*[^/])$ $1/ break; 84 | } 85 | root $webdav_root; 86 | dav_methods DELETE; 87 | } 88 | location @copy_move_handler { 89 | internal; 90 | 91 | open_file_cache off; 92 | if (-d $webdav_root/$uri) { # Microsoft specific handle: Add trailing slash to dirs. 93 | more_set_input_headers 'Destination: $http_destination/'; 94 | rewrite ^(.*[^/])$ $1/ break; 95 | } 96 | root $webdav_root; 97 | dav_methods COPY MOVE; 98 | } 99 | } 100 | --------------------------------------------------------------------------------