Last active
July 20, 2018 12:09
-
-
Save zz-chen/653551c3d7203012b37c39297f3f8bd3 to your computer and use it in GitHub Desktop.
WebDAV Server (docker) and Upload command
This file contains hidden or 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
version: '2' | |
services: | |
webdav: | |
build: . | |
ports: | |
- "80:80" | |
volumes: | |
- "/tmp:/media" | |
environment: | |
USERNAME: user | |
PASSWORD: passwd |
This file contains hidden or 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
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;" |
This file contains hidden or 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
#!/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 |
This file contains hidden or 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
curl -u user:passwd -v --upload-file /mnt/c/TMP/test.sql "http://192.168.56.101/curl-upload-$(uuidgen).txt" |
This file contains hidden or 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
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