1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-08-02 19:55:18 +02:00

Enhance Nginx configuration for protected media files with PDF handling

This commit is contained in:
Sean Morley 2025-05-22 16:26:50 -04:00
parent f96b6f5f65
commit 14e71626f6

View file

@ -36,10 +36,19 @@ http {
# Serve protected media files with X-Accel-Redirect
location /protectedMedia/ {
internal; # Only internal requests are allowed
alias /code/media/; # This should match Django MEDIA_ROOT
try_files $uri =404; # Return a 404 if the file doesn't exist
}
internal;
alias /code/media/;
try_files $uri =404;
# Nested location for PDFs
location ~* \.pdf$ {
add_header Content-Security-Policy "default-src 'self'; script-src 'none'; object-src 'none'; base-uri 'none'" always;
add_header X-Content-Type-Options nosniff always;
add_header X-Frame-Options SAMEORIGIN always;
add_header Content-Disposition "inline" always;
}
}
}
}