Enhance Nginx configuration for protected media files with PDF handling
This commit is contained in:
@@ -36,10 +36,19 @@ http {
|
|||||||
|
|
||||||
# Serve protected media files with X-Accel-Redirect
|
# Serve protected media files with X-Accel-Redirect
|
||||||
location /protectedMedia/ {
|
location /protectedMedia/ {
|
||||||
internal; # Only internal requests are allowed
|
internal;
|
||||||
alias /code/media/; # This should match Django MEDIA_ROOT
|
alias /code/media/;
|
||||||
try_files $uri =404; # Return a 404 if the file doesn't exist
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user