-
Notifications
You must be signed in to change notification settings - Fork 12
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
Oliver Lazovic
committed
Apr 30, 2016
1 parent
6227191
commit d8b510d
Showing
6 changed files
with
148 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,3 @@ | ||
.idea | ||
vendor | ||
composer* |
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,31 @@ | ||
FROM debian:jessie | ||
MAINTAINER [email protected] | ||
|
||
RUN apt-get update && \ | ||
apt-get upgrade -y && \ | ||
apt-get install -y nginx php5-fpm && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Default webdav user (CHANGE THIS!) | ||
ENV WEBDAV_USERNAME admin | ||
ENV WEBDAV_PASSWORD admin | ||
|
||
# Configure directories and composer. | ||
COPY install.sh /install.sh | ||
CMD /install.sh | ||
|
||
# Configure nginx | ||
RUN rm -rf /etc/nginx/sites-enabled/* | ||
COPY default /etc/nginx/sites-enabled/default | ||
RUN rm /etc/nginx/fastcgi_params | ||
COPY fastcgi_params /etc/nginx/fastcgi_params | ||
RUN service nginx restart | ||
|
||
# forward request and error logs to docker log collector | ||
RUN ln -sf /dev/stdout /var/log/nginx/access.log | ||
RUN ln -sf /dev/stderr /var/log/nginx/error.log | ||
|
||
# copy server.php for client -- sabredav communication | ||
COPY /server.php /var/webdav/server.php | ||
|
||
VOLUME /var/webdav/public |
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,20 @@ | ||
server { | ||
listen 80 default_server; | ||
root /var/webdav; | ||
|
||
index index.html index.htm index.php; | ||
|
||
server_name _; | ||
|
||
location / { | ||
# First attempt to serve request as file, then | ||
# as directory, then fall back to displaying a 404. | ||
try_files $uri $uri/ =404; | ||
} | ||
location ~ [^/]\.php(/|$) { | ||
fastcgi_split_path_info ^(.+?\.php)(/.*)$; | ||
fastcgi_pass unix:/var/run/php5-fpm.sock; | ||
fastcgi_index index.php; | ||
include fastcgi_params; | ||
} | ||
} |
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 @@ | ||
fastcgi_param QUERY_STRING $query_string; | ||
fastcgi_param REQUEST_METHOD $request_method; | ||
fastcgi_param CONTENT_TYPE $content_type; | ||
fastcgi_param CONTENT_LENGTH $content_length; | ||
|
||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | ||
fastcgi_param SCRIPT_NAME $fastcgi_script_name; | ||
fastcgi_param PATH_INFO $fastcgi_path_info; | ||
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; | ||
fastcgi_param REQUEST_URI $request_uri; | ||
fastcgi_param DOCUMENT_URI $document_uri; | ||
fastcgi_param DOCUMENT_ROOT $document_root; | ||
fastcgi_param SERVER_PROTOCOL $server_protocol; | ||
|
||
fastcgi_param GATEWAY_INTERFACE CGI/1.1; | ||
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; | ||
|
||
fastcgi_param REMOTE_ADDR $remote_addr; | ||
fastcgi_param REMOTE_PORT $remote_port; | ||
fastcgi_param SERVER_ADDR $server_addr; | ||
fastcgi_param SERVER_PORT $server_port; | ||
fastcgi_param SERVER_NAME $server_name; | ||
|
||
fastcgi_param HTTPS $https; | ||
|
||
# PHP only, required if PHP was built with --enable-force-cgi-redirect | ||
fastcgi_param REDIRECT_STATUS 200; |
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,31 @@ | ||
#!/bin/bash | ||
|
||
############################################################################### | ||
# This is an install script for my Docker WebDAV (based on nginx) approach. | ||
# Author: Oliver Lazovic (https://www.xama.us) | ||
############################################################################### | ||
|
||
# Directories | ||
mkdir /var/webdav | ||
chmod -R 755 /var/webdav | ||
|
||
# Working directory | ||
cd /var/webdav | ||
|
||
# SabreDAV Directories | ||
mkdir data | ||
mkdir public | ||
touch .htdigest | ||
chmod a+rwx data public .htdigest | ||
|
||
# Install composer | ||
php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php | ||
php composer-setup.php --install-dir=/usr/bin --filename=composer # As executable | ||
php -r "unlink('composer-setup.php');" | ||
|
||
# Fetch SabreDAV | ||
composer require sabre/dav ~3.1.3 | ||
composer update sabre/dav | ||
|
||
# Create authentication file | ||
echo "$WEBDAV_USERNAME:SabreDAV:$(php -r "echo md5('$WEBDAV_USERNAME:SabreDAV:$WEBDAV_PASSWORD');")" >> .htdigest |
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,36 @@ | ||
<?php | ||
require("vendor/autoload.php"); | ||
|
||
/** | ||
* This is a simple implementation of SabreDAV. | ||
* @author xama (https://www.xama.us) | ||
* @version 1.0 | ||
* @license none | ||
*/ | ||
|
||
use Sabre\DAV; | ||
use Sabre\DAV\Auth; | ||
|
||
$rootDirectory = new DAV\FS\Directory('public'); | ||
|
||
/* Configure Server */ | ||
$server = new DAV\Server($rootDirectory); | ||
$server->setBaseUri('/server.php'); | ||
|
||
/* Configure lock plugin */ | ||
$lockBackend = new DAV\Locks\Backend\File('data/locks'); | ||
$lockPlugin = new DAV\Locks\Plugin($lockBackend); | ||
$server->addPlugin($lockPlugin); | ||
|
||
/* Configure digest auth */ | ||
$authBackend = new Auth\Backend\File(__DIR__ . DIRECTORY_SEPARATOR . ".htdigest"); | ||
$authBackend->setRealm('SabreDAV'); | ||
$authPlugin = new Auth\Plugin($authBackend); | ||
|
||
/* Load plugins */ | ||
$server->addPlugin(new DAV\Browser\Plugin()); | ||
$server->addPlugin($authPlugin); | ||
|
||
/* Run the server */ | ||
$server->exec(); | ||
|