-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: WebDAV | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
paths: | ||
- 'nginx-webdav/**' | ||
|
||
jobs: | ||
|
||
nginx-webdav: | ||
name: Deploy WebDAV Image | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Publish Docker Image | ||
uses: openzim/docker-publish-action@v10 | ||
with: | ||
image-name: kiwix/nginx-webdav | ||
on-master: latest | ||
restrict-to: kiwix/container-images | ||
context: nginx-webdav | ||
registries: ghcr.io | ||
credentials: | ||
GHCRIO_USERNAME=${{ secrets.GHCR_USERNAME }} | ||
GHCRIO_TOKEN=${{ secrets.GHCR_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
FROM debian:bookworm-slim | ||
|
||
COPY webdav.conf /etc/nginx/conf.d/default.conf | ||
COPY entrypoint.sh /usr/local/bin/entrypoint | ||
|
||
RUN \ | ||
apt-get update \ | ||
&& apt-get upgrade -y \ | ||
&& apt-get install -y dumb-init curl \ | ||
# nginx and its plugins for webdav and fancyindex | ||
nginx nginx-extras libnginx-mod-http-dav-ext libnginx-mod-http-auth-pam libnginx-mod-http-fancyindex \ | ||
# apache2-utils to create htpasswd from ENVIRON in entrypoint | ||
apache2-utils \ | ||
&& rm /etc/nginx/sites-enabled/* \ | ||
&& mkdir -p /var/www/fancyindex-themes \ | ||
# fancyindex them | ||
&& curl -L -o /tmp/theme.tar.gz https://github.com/alehaa/nginx-fancyindex-flat-theme/releases/download/v1.2/nginx-fancyindex-flat-theme-1.2.tar.gz \ | ||
&& tar -C /var/www/fancyindex-themes/ --strip-components 1 -x -f /tmp/theme.tar.gz \ | ||
# another theme | ||
# && curl -L -o /tmp/theme.tar.gz https://github.com/fraoustin/Nginx-Fancyindex-Theme/archive/refs/tags/0.1.7.tar.gz \ | ||
# && tar -C /var/www/fancyindex-themes/ --strip-components 1 -x -f /tmp/theme.tar.gz \ | ||
&& mkdir -p "/data" \ | ||
&& chown -R www-data:www-data /data \ | ||
&& chmod +x /usr/local/bin/entrypoint | ||
|
||
WORKDIR /data | ||
VOLUME /data | ||
EXPOSE 80 | ||
ENV USERNAME "" | ||
ENV PASSWORD "" | ||
ENV NAME "" | ||
|
||
ENTRYPOINT ["/usr/bin/dumb-init", "--"] | ||
CMD ["/usr/local/bin/entrypoint" , "nginx", "-g", "daemon off;"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# nginx-webdav | ||
|
||
Simple nginx image for serving static files over HTTP and managing them using WebDAV using `USERNAME` and `PASSWORD` environ variables. `NAME` variable allows customizing the displayed name/title. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
if [[ -n "$USERNAME_FILE" ]] && [[ -n "$PASSWORD_FILE" ]] | ||
then | ||
USERNAME=$(cat "$USERNAME_FILE") | ||
PASSWORD=$(cat "$PASSWORD_FILE") | ||
fi | ||
|
||
if [[ -n "$USERNAME" ]] && [[ -n "$PASSWORD" ]] | ||
then | ||
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 /etc/nginx/htpasswd;% %g' /etc/nginx/conf.d/default.conf | ||
fi | ||
|
||
if [[ -n "NAME" ]] | ||
then | ||
sed -i "s/ File Browser/${NAME}/g" /var/www/fancyindex-themes/header.html | ||
sed -i "s/ FancyIndex/${NAME}/g" /var/www/fancyindex-themes/header.html | ||
fi | ||
|
||
exec "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
server { | ||
listen 80; | ||
|
||
access_log /dev/stdout; | ||
error_log /dev/stdout info; | ||
|
||
client_max_body_size 0; | ||
|
||
location / { | ||
charset utf-8; | ||
|
||
#autoindex on; | ||
#autoindex_exact_size off; | ||
#autoindex_localtime on; | ||
|
||
fancyindex on; | ||
fancyindex_exact_size off; | ||
fancyindex_show_path on; | ||
fancyindex_name_length 255; | ||
fancyindex_header "/fancyindex/header.html"; | ||
fancyindex_footer "/fancyindex/footer.html"; | ||
# fancyindex_css_href /fancyindex/theme.css; | ||
fancyindex_time_format "%B %e, %Y"; | ||
|
||
location /fancyindex { | ||
alias /var/www/fancyindex-themes; | ||
} | ||
|
||
create_full_put_path on; | ||
dav_methods PUT DELETE MKCOL COPY MOVE; | ||
dav_ext_methods PROPFIND OPTIONS; | ||
dav_access user:rw group:rw all:r; | ||
|
||
limit_except GET PROPFIND OPTIONS HEAD { | ||
auth_basic "Restricted"; | ||
auth_basic_user_file /etc/nginx/htpasswd; | ||
} | ||
|
||
root /data/; | ||
} | ||
} |