-
Notifications
You must be signed in to change notification settings - Fork 8
/
docker-compose.yml
99 lines (88 loc) · 3.5 KB
/
docker-compose.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
version: '2.2'
services:
# Run nginx on port 8080. WebDav upload and delete works.
nginx:
image: alpine:3.13
# image: nginx:1.14-alpine
ports:
- 8080:80
volumes:
- ./autoindex.xslt:/autoindex.xslt:ro
- nginx-data:/usr/share/nginx/html
entrypoint:
- /bin/sh
command:
- -c
- |
#!/bin/sh
set -e
# Install ngixx with ngx_http_xslt_filter_module and ngx_http_dav_ext_module
apk add --no-cache nginx nginx-mod-http-xslt-filter nginx-mod-http-dav-ext
# Enable the ngx_http_xslt_filter_module and ngx_http_dav_ext_module in nginx.conf
cat - > /etc/nginx/nginx.conf <<'EOF'
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
load_module "/usr/lib/nginx/modules/ngx_http_xslt_filter_module.so";
load_module "/usr/lib/nginx/modules/ngx_http_dav_ext_module.so";
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$$remote_addr - $$remote_user [$$time_local] "$$request" '
'$$status $$body_bytes_sent "$$http_referer" '
'"$$http_user_agent" "$$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
EOF
# Enable xslt autoindexing and WebDav in default.conf
cat - > /etc/nginx/conf.d/default.conf <<'EOF'
server {
listen 80;
# server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
# Enable xslt autoindexing
autoindex on;
autoindex_format xml;
autoindex_exact_size off;
autoindex_localtime off;
xslt_stylesheet /autoindex.xslt;
# Enable WebDav
client_body_temp_path /srv/temp; # Set to path where WebDav will save temporary files
dav_methods PUT DELETE;
add_header X-Options "WebDav"; # Important!
create_full_put_path on;
dav_access group:rw all:r;
client_max_body_size 1000M; # Change this as you need
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
EOF
# Create some fake files
rm -rf /usr/share/nginx/html/*
touch /usr/share/nginx/html/hello.txt
mkdir -p /usr/share/nginx/html/music
touch /usr/share/nginx/html/music/hello.mp3
mkdir -p /usr/share/nginx/html/videos
touch /usr/share/nginx/html/videos/hello.mp4
ls -al /usr/share/nginx/html
chown -R nginx:nginx /usr/share/nginx/html
# Run nginx: https://github.com/nginxinc/docker-nginx/blob/1.21.4/mainline/alpine/Dockerfile
ln -sf /dev/stdout /var/log/nginx/access.log
ln -sf /dev/stderr /var/log/nginx/error.log
exec nginx -g 'daemon off;'
volumes:
nginx-data: