Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:10.6-slim
FROM debian:12.5-slim as debian_base

LABEL maintainer "ugeek. ugeekpodcast@gmail.com"

Expand All @@ -9,9 +9,16 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends \
nginx \
nginx-extras \
apache2-utils && \
apache2-utils \
logrotate && \
rm -rf /var/lib/apt/lists

FROM debian_base as debian_logs

COPY ./nginx_log_rotate /etc/logrotate.d/nginx
RUN /usr/sbin/logrotate -f /etc/logrotate.conf

FROM debian_logs
RUN usermod -u $UID www-data && groupmod -g $GID www-data

VOLUME /media
Expand Down
29 changes: 19 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Servidor webdav partiendo de debian-testing

## Clonar el repositorio
## Clonar el repositorio

```
git clone https://github.com/uGeek/docker-nginx-webdav.git
Expand All @@ -13,32 +13,39 @@ cd docker-nginx-webdav
```

## Construir la imagen

```
docker build -t ugeek/webdav:arm .
```

## Ver el número de imagen:

```
docker images
```

## Montar el contenedor

### docker-cli

USERNAME: webdav
PASSWORD: webdav
PUERTO: 80
MAXIMO 50 USUARIOS

--restart=unless-stopped: Iniciar cada vez que iniciemos el servidor


```
docker run --name webdav \
--restart=unless-stopped \
-p 80:80 \
-v $HOME/docker/webdav:/media \
-e USERNAME=webdav \
-e PASSWORD=webdav \
-e USERNAME1=webdav \
-e PASSWORD1=webdav \
-e USERNAME2=webdav \
-e PASSWORD2=webdav \
-e TZ=Europe/Madrid \
-e UDI=1000 \
-e GID=1000 \
Expand All @@ -60,13 +67,17 @@ services:
environment:
- USERNAME=webdav
- PASSWORD=webdav
- USERNAME1=${USER1}
- PASSWORD1=${PASSWORD1}
- USERNAME2=${USER2}
- PASSWORD2=${PASSWORD2}
- UID=1000
- GID=1000
- TZ=Europe/Madrid
networks:
- web
labels:
- traefik.backend=webdav
- traefik.backend=webdav
- traefik.frontend.rule=Host:webdav.tu_dominio.duckdns.org
- traefik.docker.network=web
- traefik.port=80
Expand All @@ -82,17 +93,17 @@ services:
- traefik.http.middlewares.securedheaders.headers.frameDeny=true
- traefik.http.middlewares.securedheaders.headers.browserXssFilter=true
- traefik.http.middlewares.securedheaders.headers.contentTypeNosniff=true
networks:
networks:
web:
external: true
external: true
```

Introduce el comando...

```
docker-compose up -d
```


## Logs

Añadido nuevo registro de logs.
Expand All @@ -109,14 +120,12 @@ docker exec -it webdav cat /var/log/nginx/webdav_access.log
docker exec -it webdav cat /var/log/nginx/webdav_access.log
```



### logs con error

```
docker exec -it webdav /var/log/nginx/webdav_error.log
```

## Agradecimientos
- 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)


- 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)
29 changes: 24 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
#!/bin/bash

touch /etc/nginx/htpasswd

if [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]
then
htpasswd -bc /etc/nginx/htpasswd $USERNAME $PASSWORD
echo Done.
else
htpasswd -b /etc/nginx/htpasswd "$USERNAME" "$PASSWORD"
echo "Done for User: $USERNAME"
fi

max_users=50
for ((i=1; i<=$max_users; i++))
do
username_var="USERNAME$i"
password_var="PASSWORD$i"

if [ -n "${!username_var}" ] && [ -n "${!password_var}" ]
then
htpasswd -b /etc/nginx/htpasswd "${!username_var}" "${!password_var}"
echo "Done for User $i: ${!username_var}"
fi
done

if [ -z "$(env | grep '^USERNAME')" ] || [ -z "$(env | grep '^PASSWORD')" ]
then
echo Using no auth.
sed -i 's%auth_basic "Restricted";% %g' /etc/nginx/conf.d/default.conf
sed -i 's%auth_basic_user_file htpasswd;% %g' /etc/nginx/conf.d/default.conf
sed -i 's%auth_basic "Restricted";% %g' /etc/nginx/conf.d/default.conf
sed -i 's%auth_basic_user_file htpasswd;% %g' /etc/nginx/conf.d/default.conf
fi

mediaowner=$(ls -ld /media | awk '{print $3}')
echo "Current /media owner is $mediaowner"
if [ "$mediaowner" != "www-data" ]
Expand Down
10 changes: 10 additions & 0 deletions nginx_log_rotate
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/var/log/nginx/*.log {
size 10M
rotate 5
compress
delaycompress
missingok
notifempty
create 0640 www-data adm
}