Skip to content

Instantly share code, notes, and snippets.

@zz-chen
Last active July 20, 2018 12:09
Show Gist options
  • Save zz-chen/653551c3d7203012b37c39297f3f8bd3 to your computer and use it in GitHub Desktop.
Save zz-chen/653551c3d7203012b37c39297f3f8bd3 to your computer and use it in GitHub Desktop.
WebDAV Server (docker) and Upload command
version: '2'
services:
webdav:
build: .
ports:
- "80:80"
volumes:
- "/tmp:/media"
environment:
USERNAME: user
PASSWORD: passwd
FROM ubuntu:trusty
RUN apt-get update && apt-get install -y nginx nginx-extras apache2-utils
VOLUME /media
EXPOSE 80
COPY webdav.conf /etc/nginx/conf.d/default.conf
RUN rm /etc/nginx/sites-enabled/*
COPY entrypoint.sh /
RUN chmod +x entrypoint.sh
CMD /entrypoint.sh && nginx -g "daemon off;"
#!/bin/bash
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 htpasswd;% %g' /etc/nginx/conf.d/default.conf
fi
curl -u user:passwd -v --upload-file /mnt/c/TMP/test.sql "http://192.168.56.101/curl-upload-$(uuidgen).txt"
server {
listen 80;
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_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw all:rw;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
root /media/;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment