From 3c7c834a37802e5ca5d93a4b4a91dde3264d9f5d Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 17 May 2020 20:24:09 +0200 Subject: nginx: Add Expires: HTTP headers. --- roles/git/files/etc/nginx/sites-available/git | 1 + roles/lists/files/etc/nginx/sites-available/sympa | 6 +++--- roles/nextcloud/files/etc/nginx/sites-available/nextcloud | 2 +- roles/webmail/files/etc/nginx/sites-available/roundcube | 1 + roles/wiki/files/etc/nginx/sites-available/website | 2 ++ roles/wiki/files/etc/nginx/sites-available/wiki | 8 +++++--- 6 files changed, 13 insertions(+), 7 deletions(-) (limited to 'roles') diff --git a/roles/git/files/etc/nginx/sites-available/git b/roles/git/files/etc/nginx/sites-available/git index 0aa4345..3f2bc7f 100644 --- a/roles/git/files/etc/nginx/sites-available/git +++ b/roles/git/files/etc/nginx/sites-available/git @@ -39,6 +39,7 @@ server { gzip_types application/javascript application/json application/xml image/svg+xml image/x-icon text/css text/plain; location ^~ /static/ { + expires 30d; alias /usr/share/cgit/; } diff --git a/roles/lists/files/etc/nginx/sites-available/sympa b/roles/lists/files/etc/nginx/sites-available/sympa index 4cfc11b..89d79f3 100644 --- a/roles/lists/files/etc/nginx/sites-available/sympa +++ b/roles/lists/files/etc/nginx/sites-available/sympa @@ -49,9 +49,9 @@ server { return 302 /sympa$args; } - location ^~ /static-sympa/ { alias /usr/share/sympa/static_content/; } - location ^~ /css-sympa/ { alias /var/lib/sympa/css/; } - location ^~ /pictures-sympa/ { alias /var/lib/sympa/pictures; } + location ^~ /static-sympa/ { expires 30d; try_files $uri =404; alias /usr/share/sympa/static_content/; } + location ^~ /css-sympa/ { expires 30d; try_files $uri =404; alias /var/lib/sympa/css/; } + location ^~ /pictures-sympa/ { expires 30d; try_files $uri =404; alias /var/lib/sympa/pictures; } location ~* ^/sympa(?:/|$) { gzip off; # protect against BREACH diff --git a/roles/nextcloud/files/etc/nginx/sites-available/nextcloud b/roles/nextcloud/files/etc/nginx/sites-available/nextcloud index e971f99..52f24e0 100644 --- a/roles/nextcloud/files/etc/nginx/sites-available/nextcloud +++ b/roles/nextcloud/files/etc/nginx/sites-available/nextcloud @@ -81,8 +81,8 @@ server { } location ~ \.(?:css|js|woff2?|svg|gif|map)$ { - try_files $uri /index.php$uri$is_args$args; expires 30d; + try_files $uri /index.php$uri$is_args$args; } location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ { diff --git a/roles/webmail/files/etc/nginx/sites-available/roundcube b/roles/webmail/files/etc/nginx/sites-available/roundcube index 6bd4dd1..9cc20ad 100644 --- a/roles/webmail/files/etc/nginx/sites-available/roundcube +++ b/roles/webmail/files/etc/nginx/sites-available/roundcube @@ -68,6 +68,7 @@ server { } location ~ "^/(?:plugins|program/js|program/resources|skins)(?:/[[:alnum:]][[:alnum:]\-\._]*)+\.(?:css|eot|gif|html|ico|jpg|js|pdf|png|svg|tiff?|ttf|webp|woff2?)$" { + expires 30d; try_files $uri =404; } location / { internal; } diff --git a/roles/wiki/files/etc/nginx/sites-available/website b/roles/wiki/files/etc/nginx/sites-available/website index cd6832a..69d3337 100644 --- a/roles/wiki/files/etc/nginx/sites-available/website +++ b/roles/wiki/files/etc/nginx/sites-available/website @@ -47,6 +47,8 @@ server { } location = /ikiwiki.cgi { internal; } location /static/ { + expires 30d; + try_files $uri =404; alias /var/lib/ikiwiki/public_html/fripost-wiki/static/; } location /material/ { diff --git a/roles/wiki/files/etc/nginx/sites-available/wiki b/roles/wiki/files/etc/nginx/sites-available/wiki index 89e86d8..153b3e2 100644 --- a/roles/wiki/files/etc/nginx/sites-available/wiki +++ b/roles/wiki/files/etc/nginx/sites-available/wiki @@ -39,15 +39,17 @@ server { gzip_min_length 256; gzip_types application/font-woff application/font-woff2 application/javascript application/json application/xml image/svg+xml image/x-icon text/css text/plain; + root /var/lib/ikiwiki/public_html/fripost-wiki; + + location /static/ { expires 30d; try_files $uri =404; } location / { location ~ ^/website(/.*)?$ { return 302 $scheme://fripost.org$1; } - try_files $uri $uri/ =404; index index.html; - root /var/lib/ikiwiki/public_html/fripost-wiki; + try_files $uri $uri/ =404; } location = /ikiwiki.cgi { - fastcgi_param DOCUMENT_ROOT /var/lib/ikiwiki/public_html/fripost-wiki; + fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SCRIPT_FILENAME /var/lib/ikiwiki/public_html/ikiwiki.cgi; fastcgi_index ikiwiki.cgi; include snippets/fastcgi.conf; -- cgit v1.2.3