Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict NGINX (public?) access to "large" files only (e.g. .mp3, .mp4, .webm) in /library/calibre-web — for PR #51 OOM workaround #57

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
41 changes: 40 additions & 1 deletion scripts/calibre-web-nginx.conf
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to keep in mind this is a temporary fix. We'll need to align with Calibre-Web architecture eventually.

Original file line number Diff line number Diff line change
@@ -1,7 +1,46 @@
# RELATED: https://github.com/janeczku/calibre-web/wiki/Setup-Reverse-Proxy

# 2023-12-04: This is part of an (interim?) workaround so that playback of
# larger videos actually works. Far better would be a proper MM (memory
# management) solution that respects Calibre-Web's existing username/password
# security model. Can anybody suggest concrete ideas to make that happen?
#
# The failure of large videos to play is summarized here:
# https://github.com/iiab/calibre-web/issues/37
#
# This (perhaps imperfect) proposed solution is emerging here:
# https://github.com/iiab/calibre-web/pull/50
# https://github.com/iiab/calibre-web/pull/51
# https://github.com/iiab/calibre-web/issues/53
# https://github.com/iiab/iiab/pull/3676
# https://github.com/iiab/calibre-web/pull/55
# https://github.com/iiab/calibre-web/pull/56
# https://github.com/iiab/calibre-web/pull/57

# http://box/library/calibre-web/<author>/<title>/<webm_or_mp4_video_file>
location /library/calibre-web/ {
alias /library/www/html/calibre-web/;
fancyindex on; # autoindex on;
# fancyindex on;
# autoindex on;

deldesir marked this conversation as resolved.
Show resolved Hide resolved
location ~* \.(webm|mp4)$ {
# Configuration specific to video files
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
expires 30d;
add_header Cache-Control "public, max-age=2592000";
try_files $uri =404; # Ensure only existing files are served
}

# Default deny for other file types and directories
location ~* ^/library/calibre-web/.*\.(?!webm|mp4)[a-z0-9]+$ {
deny all;
access_log off;
log_not_found off;
}

location ~* ^/library/calibre-web/.*[^/]*$ {
deny all;
access_log off;
log_not_found off;
}
}