code cleanup
This commit is contained in:
+37
-9
@@ -22,6 +22,14 @@ http {
|
||||
gzip on;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml;
|
||||
|
||||
# WebDAV cache zone definition
|
||||
proxy_cache_path /meta-core/cache
|
||||
levels=1:2 # 2-level directory structure
|
||||
keys_zone=webdav_cache:10m # 10MB shared memory for keys
|
||||
max_size=10g # Max 10GB on disk
|
||||
inactive=1h # Remove if not accessed for 1 hour
|
||||
use_temp_path=off; # Write directly to cache dir
|
||||
|
||||
# Upstream: meta-core Go API
|
||||
upstream meta-core-api {
|
||||
server 127.0.0.1:9000;
|
||||
@@ -192,11 +200,33 @@ http {
|
||||
}
|
||||
|
||||
# =========================================================================
|
||||
# WebDAV endpoint for file access (proxied to Go for caching)
|
||||
# WebDAV endpoint for file access (nginx proxy_cache for GET/HEAD)
|
||||
# Supports: GET (read), PUT (write), DELETE, MKCOL (mkdir), PROPFIND
|
||||
# Files are cached by the Go service for faster repeated access
|
||||
# Files are cached by nginx for faster repeated access
|
||||
# =========================================================================
|
||||
location /webdav/ {
|
||||
# Slice module for large file chunked caching
|
||||
slice 1m;
|
||||
proxy_cache_key $uri$slice_range;
|
||||
proxy_set_header Range $slice_range;
|
||||
|
||||
# Enable caching for GET/HEAD requests
|
||||
proxy_cache webdav_cache;
|
||||
proxy_cache_valid 200 206 1h;
|
||||
proxy_cache_methods GET HEAD;
|
||||
|
||||
# Don't cache write operations
|
||||
set $no_cache 0;
|
||||
if ($request_method !~ ^(GET|HEAD)$) {
|
||||
set $no_cache 1;
|
||||
}
|
||||
proxy_no_cache $no_cache;
|
||||
proxy_cache_bypass $no_cache;
|
||||
|
||||
# Cache status header for debugging
|
||||
add_header X-Cache-Status $upstream_cache_status always;
|
||||
|
||||
# Proxy settings
|
||||
proxy_pass http://meta-core-api/webdav/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
@@ -204,14 +234,12 @@ http {
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
# Disable buffering for streaming and large files
|
||||
proxy_buffering off;
|
||||
proxy_request_buffering off;
|
||||
# Enable buffering for caching (required for proxy_cache)
|
||||
proxy_buffering on;
|
||||
proxy_request_buffering off; # Don't buffer uploads
|
||||
|
||||
# No size limit for uploads (large media files)
|
||||
# Large file support
|
||||
client_max_body_size 0;
|
||||
|
||||
# Timeout settings for large files
|
||||
proxy_read_timeout 600s;
|
||||
proxy_send_timeout 600s;
|
||||
|
||||
@@ -219,7 +247,7 @@ http {
|
||||
add_header 'Access-Control-Allow-Origin' '*' always;
|
||||
add_header 'Access-Control-Allow-Methods' 'GET, HEAD, PUT, DELETE, MKCOL, COPY, MOVE, PROPFIND, OPTIONS' always;
|
||||
add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type, Depth, Destination, Range, If-Range' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length, Content-Range, Accept-Ranges' always;
|
||||
add_header 'Access-Control-Expose-Headers' 'Content-Length, Content-Range, Accept-Ranges, X-Cache-Status' always;
|
||||
|
||||
# Handle OPTIONS preflight
|
||||
if ($request_method = 'OPTIONS') {
|
||||
|
||||
Reference in New Issue
Block a user