From 314b842109c93c9a02b89d196cbd285e6c211cef Mon Sep 17 00:00:00 2001 From: leccelecce <24962424+leccelecce@users.noreply.github.com> Date: Wed, 19 Mar 2025 11:45:31 +0000 Subject: [PATCH] Nginx: disable open_file_cache if media is on NFS --- docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run | 9 +++++++++ docker/main/rootfs/usr/local/nginx/conf/nginx.conf | 5 +---- .../rootfs/usr/local/nginx/conf/open_file_cache.conf | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 docker/main/rootfs/usr/local/nginx/conf/open_file_cache.conf diff --git a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run index 273182930..d86d686b3 100755 --- a/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run +++ b/docker/main/rootfs/etc/s6-overlay/s6-rc.d/nginx/run @@ -89,6 +89,15 @@ python3 /usr/local/nginx/get_tls_settings.py | \ tempio -template /usr/local/nginx/templates/listen.gotmpl \ -out /usr/local/nginx/conf/listen.conf +# disable open_file_cache on NFS filesystems +# https://trac.nginx.org/nginx/ticket/478 +NFS_CLIPS_FS=`findmnt -n -o FSTYPE --target /media/frigate/clips` + +shopt -s nocasematch; if [[ "$NFS_CLIPS_FS" =~ ^nfs* ]]; then + echo "[INFO] NFS mount detected for /media/frigate/clips, disabling NGINX open_file_cache" + echo "open_file_cache off;" > /usr/local/nginx/conf/open_file_cache.conf +fi + # Replace the bash process with the NGINX process, redirecting stderr to stdout exec 2>&1 exec \ diff --git a/docker/main/rootfs/usr/local/nginx/conf/nginx.conf b/docker/main/rootfs/usr/local/nginx/conf/nginx.conf index 6c60019c7..deab9a9a1 100644 --- a/docker/main/rootfs/usr/local/nginx/conf/nginx.conf +++ b/docker/main/rootfs/usr/local/nginx/conf/nginx.conf @@ -75,10 +75,7 @@ http { vod_hls_mpegts_interleave_frames on; # file handle caching / aio - open_file_cache max=1000 inactive=5m; - open_file_cache_valid 2m; - open_file_cache_min_uses 1; - open_file_cache_errors on; + include open_file_cache.conf; aio on; # file upload size diff --git a/docker/main/rootfs/usr/local/nginx/conf/open_file_cache.conf b/docker/main/rootfs/usr/local/nginx/conf/open_file_cache.conf new file mode 100644 index 000000000..6511bbe0f --- /dev/null +++ b/docker/main/rootfs/usr/local/nginx/conf/open_file_cache.conf @@ -0,0 +1,4 @@ +open_file_cache max=1000 inactive=5m; +open_file_cache_valid 2m; +open_file_cache_min_uses 1; +open_file_cache_errors on; \ No newline at end of file