From e062d42e6648be2bd49cdfb1084a6e1ea8284d62 Mon Sep 17 00:00:00 2001 From: Max Schmidt Date: Tue, 24 Oct 2023 09:46:18 +0200 Subject: [PATCH] Update nginx.conf with gzip configurations and server block for static file caching and serving --- astro/nginx.conf | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/astro/nginx.conf b/astro/nginx.conf index db2dd99..e057de4 100644 --- a/astro/nginx.conf +++ b/astro/nginx.conf @@ -1,6 +1,7 @@ events { worker_connections 1024; } + http { gzip on; gzip_vary on; @@ -9,14 +10,19 @@ http { gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + server { listen 3000; - location ~* \.(jpg|jpeg|png|gif|ico|css|js|htm|html)$ { - expires 30d; # set long caching period on static files - add_header Pragma public; - add_header Cache-Control "public"; - try_files $uri $uri/ =404; # serve file if it exists, otherwise 404 + + location / { + root /usr/share/nginx/html; + try_files $uri $uri/ =404; } + location ~* \.(jpg|jpeg|png|gif|ico|css|js|htm|html)$ { + expires 30d; + add_header Pragma public; + add_header Cache-Control "public"; + } } -} +} \ No newline at end of file