add nginx and build webdav

This commit is contained in:
Lorenzo 2022-02-04 05:53:18 +01:00
parent 2a0e96bc25
commit 6e183c75ad
14 changed files with 251 additions and 9 deletions

32
nginx/Dockerfile Normal file
View File

@ -0,0 +1,32 @@
FROM nginx:stable-alpine
ARG UID=${UID:-1000}
ARG GID=${GID:-1000}
RUN apk add --update \
--no-cache \
tini \
shadow \
rm -rf /var/cache/apk && \
groupmod -g $GID www-data && \
adduser -u $UID -S www-data -G www-data && \
mkdir /html
COPY default.conf /etc/nginx/conf.d/default.conf
COPY entrypoint.sh /
EXPOSE 8080
VOLUME /html
RUN chown -R www-data:www-data /html && \
chown -R www-data:www-data /var/cache/nginx && \
chown -R www-data:www-data /var/log/nginx && \
chown -R www-data:www-data /etc/nginx && \
touch /var/run/nginx.pid && \
chown -R www-data:www-data /var/run/nginx.pid
USER www-data
ENTRYPOINT ["tini", "--"]
CMD ["/bin/sh", "/entrypoint.sh"]

21
nginx/LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Alexander Gorokhov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

9
nginx/README.md Normal file
View File

@ -0,0 +1,9 @@
# Installation
```
git clone https://github.com/atareao/self-hosted.git
cd self-hosted/nginx
mkdir html
docker-compose up -d
docker-compose logs -f
```

15
nginx/default.conf Normal file
View File

@ -0,0 +1,15 @@
server {
listen 8080 default_server;
root /html;
index index.php index.html index.htm index.html;
server_name localhost;
access_log /dev/stdout;
error_log /dev/stdout info;
location / {
try_files $uri $uri/ =404;
}
}

11
nginx/docker-compose.yml Normal file
View File

@ -0,0 +1,11 @@
version: '3'
services:
nginx:
build: .
image: atareao/nginx:v1.0
container_name: nginx
restart: unless-stopped
ports:
- 8080:8080
volumes:
- ./html:/html

8
nginx/entrypoint.sh Normal file
View File

@ -0,0 +1,8 @@
#!/bin/bash
mediaowner=$(ls -ld /html | awk '{print $3}')
echo "Current /html owner is $mediaowner"
if [ "$mediaowner" != "www-data" ]
then
chown -R www-data:www-data /html
fi
nginx -g "daemon off;"

34
nginx/html/index.html Normal file
View File

@ -0,0 +1,34 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A Basic HTML5 Template</title>
<meta name="description" content="A simple HTML5 Template for new projects.">
<meta name="author" content="SitePoint">
<meta property="og:title" content="A Basic HTML5 Template">
<meta property="og:type" content="website">
<meta property="og:url" content="https://www.sitepoint.com/a-basic-html5-template/">
<meta property="og:description" content="A simple HTML5 Template for new projects.">
<meta property="og:image" content="image.png">
<link rel="icon" href="/favicon.ico">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/apple-touch-icon.png">
<link rel="stylesheet" href="css/styles.css?v=1.0">
</head>
<body>
<!-- your content here... -->
<h1>Hola mundo</h1>
<p>Bienvenido al maravilloso mundo de los contenedores</p>
<!-- your content here... -->
<script src="js/scripts.js"></script>
</body>
</html>

33
webdav/Dockerfile Normal file
View File

@ -0,0 +1,33 @@
FROM nginx:stable-alpine
ARG UID=${UID:-1000}
ARG GID=${GID:-1000}
RUN apk add --update \
--no-cache \
tini \
shadow \
apache2-utils && \
rm -rf /var/cache/apk && \
groupmod -g $GID www-data && \
adduser -u $UID -S www-data -G www-data && \
mkdir /share
COPY webdav.conf /etc/nginx/conf.d/default.conf
COPY entrypoint.sh /
EXPOSE 8080
VOLUME /share
RUN chown -R www-data:www-data /share && \
chown -R www-data:www-data /var/cache/nginx && \
chown -R www-data:www-data /var/log/nginx && \
chown -R www-data:www-data /etc/nginx && \
touch /var/run/nginx.pid && \
chown -R www-data:www-data /var/run/nginx.pid
USER www-data
ENTRYPOINT ["tini", "--"]
CMD ["/bin/sh", "/entrypoint.sh"]

21
webdav/LICENSE Normal file
View File

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2016 Alexander Gorokhov
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,15 +1,26 @@
# Installation
# Servidor webdav partiendo de alpine
⚠ First! Change `user` and `password` in `docker-compose`
## Clonar el repositorio
```
git clone https://github.com/atareao/docker-webdav.git
```
y accedemos al interior de la carpeta:
```
cd docker-webdav
```
## Crea el directorio
Tienes que crear el directorio y añadir todos los archivos y subdirectorios que quieras compartir,
```
git clone git@github.com:atareao/self-hosted.git
cd self-hosted/webdav
sed -i "s/user/your-user/" docker-compose.yml
sed -i "s/passwd/your-password/" docker-compose.yml
mkdir share
docker-compose up -d
docker-compose logs -f
```
After this, open webbrowser at `http://localhost:8080`, and use `user` and `password` as configured.
USERNAME: user
PASSWORD: passwd
Ya puedes acceder a través de `http://localhost:8080`

View File

@ -1,6 +1,7 @@
version: '3'
services:
webdav:
build: .
image: atareao/webdav:v1.1
container_name: webdav
restart: unless-stopped

21
webdav/entrypoint.sh Normal file
View File

@ -0,0 +1,21 @@
#!/bin/bash
if [ -n "$USERNAME" ] && [ -n "$PASSWORD" ]
then
echo $USERNAME
echo $PASSWORD
echo "Mod htpasswd"
htpasswd -bc /etc/nginx/htpasswd $USERNAME $PASSWORD
echo Done.
else
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
fi
mediaowner=$(ls -ld /share | awk '{print $3}')
echo "Current /share owner is $mediaowner"
if [ "$mediaowner" != "www-data" ]
then
chown -R www-data:www-data /share
fi
nginx -g "daemon off;"

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

25
webdav/webdav.conf Normal file
View File

@ -0,0 +1,25 @@
server {
listen 8080;
access_log /dev/stdout;
error_log /dev/stdout info;
client_max_body_size 0;
location / {
create_full_put_path on;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
charset utf-8;
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_access user:rw group:rw all:rw;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
root /share/;
}
}