From 60f996813487f9315586f721be05dbbc2f8d0beb Mon Sep 17 00:00:00 2001 From: andryyy Date: Thu, 31 Jan 2019 15:45:57 +0100 Subject: [PATCH] [Nginx] Add compression, change expires --- data/conf/nginx/site.conf | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/data/conf/nginx/site.conf b/data/conf/nginx/site.conf index 67d6f1a1..9087edf3 100644 --- a/data/conf/nginx/site.conf +++ b/data/conf/nginx/site.conf @@ -7,15 +7,6 @@ map $http_x_forwarded_proto $client_req_scheme { https https; } -map $sent_http_content_type $expires { - default off; - text/html off; - text/css 1d; - application/javascript 1d; - application/json off; - image/png 1d; -} - server { include /etc/nginx/mime.types; charset utf-8; @@ -47,6 +38,17 @@ server { include /etc/nginx/conf.d/listen_ssl.active; include /etc/nginx/conf.d/server_name.active; + gzip on; + gzip_disable "msie6"; + + gzip_vary on; + gzip_proxied any; + gzip_comp_level 6; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_min_length 256; + gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf font/opentype image/svg+xml image/x-icon; + error_log /var/log/nginx/error.log; access_log /var/log/nginx/access.log; absolute_redirect off; @@ -105,7 +107,6 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_redirect off; - expires $expires; } location ~* ^/Autodiscover/Autodiscover.xml { @@ -185,5 +186,14 @@ server { alias /usr/lib/GNUstep/SOGo/$1.SOGo/Resources/$2; } + location ~* \.(?:css|js|ico|woff|eot|svg|ttf|otf|png|gif|jpe?g) { + access_log off; + add_header Cache-Control public; + } + + location ~* \.(?:css|js|woff|eot|svg|ttf|otf|png|gif|jpe?g) { + expires max; + } + include /etc/nginx/conf.d/site.*.custom; }