From 1bbb96230c6d3a157dc2e3eb731fff419537677a Mon Sep 17 00:00:00 2001 From: Goten Xiao Date: Sat, 23 Apr 2022 22:13:57 +0100 Subject: [PATCH] Use conditional slicing --- overlay/etc/nginx/conf.d/31_slice_maps.conf | 4 ++++ .../etc/nginx/sites-available/cache.conf.d/root/20_cache.conf | 3 ++- .../nginx/sites-available/cache.conf.d/root/30_cache_key.conf | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 overlay/etc/nginx/conf.d/31_slice_maps.conf diff --git a/overlay/etc/nginx/conf.d/31_slice_maps.conf b/overlay/etc/nginx/conf.d/31_slice_maps.conf new file mode 100644 index 0000000..3025356 --- /dev/null +++ b/overlay/etc/nginx/conf.d/31_slice_maps.conf @@ -0,0 +1,4 @@ +map "${cacheidentifier}${http_range}" $slice_range_actual { + default $slice_range; # Use the calculated slice range by default + ~steam$ ""; # Disable slicing for Steam when the client request isn't a range, as not all CDN nodes accept range requests +} diff --git a/overlay/etc/nginx/sites-available/cache.conf.d/root/20_cache.conf b/overlay/etc/nginx/sites-available/cache.conf.d/root/20_cache.conf index 4fb1ce4..e016760 100644 --- a/overlay/etc/nginx/sites-available/cache.conf.d/root/20_cache.conf +++ b/overlay/etc/nginx/sites-available/cache.conf.d/root/20_cache.conf @@ -4,7 +4,8 @@ proxy_ignore_headers Expires Cache-Control; proxy_cache_valid 200 206 CACHE_MAX_AGE; - proxy_set_header Range $slice_range; + # $slice_range_actual is set from the map in 31_slice_maps.conf + proxy_set_header Range $slice_range_actual; # Only download one copy at a time and use a large timeout so # this really happens, otherwise we end up wasting bandwith diff --git a/overlay/etc/nginx/sites-available/cache.conf.d/root/30_cache_key.conf b/overlay/etc/nginx/sites-available/cache.conf.d/root/30_cache_key.conf index e2d5580..c406a4b 100644 --- a/overlay/etc/nginx/sites-available/cache.conf.d/root/30_cache_key.conf +++ b/overlay/etc/nginx/sites-available/cache.conf.d/root/30_cache_key.conf @@ -1 +1 @@ - proxy_cache_key $cacheidentifier$uri$slice_range; + proxy_cache_key $cacheidentifier$uri$slice_range_actual;