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: