From 71a429c7a26f03fb8873b855ff154e2ea6d67914 Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Wed, 9 Feb 2022 14:00:12 +0100 Subject: [PATCH] Update to 2022-02-09 14:00 --- .../templates/ansible_conf.d/09-cacheable.conf.j2 | 11 ++++++++++- roles/nginx/templates/ansible_conf.d/10-cache.conf.j2 | 2 +- roles/nginx/templates/ansible_conf.d/10-perf.conf.j2 | 4 ++-- roles/nginx/templates/ansible_conf.d/perf.inc.j2 | 8 +++++++- .../templates/nginx_vhost.conf.j2 | 6 ++++++ 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/roles/nginx/templates/ansible_conf.d/09-cacheable.conf.j2 b/roles/nginx/templates/ansible_conf.d/09-cacheable.conf.j2 index 3ce290d..9de412d 100644 --- a/roles/nginx/templates/ansible_conf.d/09-cacheable.conf.j2 +++ b/roles/nginx/templates/ansible_conf.d/09-cacheable.conf.j2 @@ -1,4 +1,4 @@ -map $upstream_http_content_type $is_cacheable { +map $sent_http_content_type $is_client_cacheable { default 0; ~image/ 1; ~audio/ 1; @@ -14,3 +14,12 @@ map $upstream_http_content_type $is_cacheable { application/vnd.ms-fontobject 1; application/vnd.ms-opentype 1; } + +map $request_uri $is_proxy_cacheable { + default 0; + ~*\.(png|jpe?g|bmp|gif|webp)$ 1; + ~*\.(js|css|txt)$ 1; + ~*\.(pdf)$ 1; + ~*\.(ttf|ott)$ 1; + ~*\.(mp3|mp4|avi|mpe?g|mov|flv)$ 1; +} diff --git a/roles/nginx/templates/ansible_conf.d/10-cache.conf.j2 b/roles/nginx/templates/ansible_conf.d/10-cache.conf.j2 index d2aa18c..907f8d6 100644 --- a/roles/nginx/templates/ansible_conf.d/10-cache.conf.j2 +++ b/roles/nginx/templates/ansible_conf.d/10-cache.conf.j2 @@ -5,7 +5,7 @@ proxy_cache_path /var/cache/nginx inactive=300m use_temp_path=off; -map $is_cacheable $no_cache { +map $is_proxy_cacheable $no_cache { default 1; 1 0; } diff --git a/roles/nginx/templates/ansible_conf.d/10-perf.conf.j2 b/roles/nginx/templates/ansible_conf.d/10-perf.conf.j2 index f80ca4a..78ccc39 100644 --- a/roles/nginx/templates/ansible_conf.d/10-perf.conf.j2 +++ b/roles/nginx/templates/ansible_conf.d/10-perf.conf.j2 @@ -1,8 +1,8 @@ -map $is_cacheable $custom_expires { +map $is_client_cacheable $custom_expires { default epoch; 1 7d; } -map $is_cacheable $custom_cache_control { +map $is_client_cacheable $custom_cache_control { default "no-cache, no-store, private"; 1 "public, max-age=604800, must-revalidate, proxy-revalidate"; } diff --git a/roles/nginx/templates/ansible_conf.d/perf.inc.j2 b/roles/nginx/templates/ansible_conf.d/perf.inc.j2 index 772276c..6fe8ae6 100644 --- a/roles/nginx/templates/ansible_conf.d/perf.inc.j2 +++ b/roles/nginx/templates/ansible_conf.d/perf.inc.j2 @@ -11,7 +11,13 @@ gzip_types application/rss+xml application/atom_xml application/x-javascript - application/javascript; + application/javascript + application/font-sfnt + font/opentype + font/ttf + application/font-woff + application/vnd.ms-fontobject + application/vnd.ms-opentype; gzip_vary on; gzip_disable "msie6"; expires $custom_expires; diff --git a/roles/onlyoffice_document_server/templates/nginx_vhost.conf.j2 b/roles/onlyoffice_document_server/templates/nginx_vhost.conf.j2 index a1dc091..e0dfe15 100644 --- a/roles/onlyoffice_document_server/templates/nginx_vhost.conf.j2 +++ b/roles/onlyoffice_document_server/templates/nginx_vhost.conf.j2 @@ -2,5 +2,11 @@ include /etc/onlyoffice/documentserver/nginx/includes/http-common.conf; server { listen 0.0.0.0:80; server_name {{ oo_ds_vhost }}; + # Override the fonts endpoint to add a Content-Type so reverse proxies can handle caching corectly + location ~ ^(\/[\d]+\.[\d]+\.[\d]+[\.|-][\d]+)?\/fonts(\/.*)$ { + add_header Content-Type font/opentype; + expires 365d; + alias /var/www/onlyoffice/documentserver/fonts$2; + } include /etc/onlyoffice/documentserver/nginx/includes/ds-docservice.conf; }