From 4e3937c8465f01823d042196e55bbc87148a67aa Mon Sep 17 00:00:00 2001 From: PetrMitin Date: Mon, 27 May 2024 17:17:15 +0300 Subject: [PATCH] general: add static caching for minio images --- nginx/nginx.conf | 4 +--- nginx/sites-available/socio.conf | 15 +++++++++++++++ nginx/sites-enabled/socio.conf | 18 ++++++++++++++++-- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 2048ee9..ba459dd 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -9,6 +9,7 @@ events { } http { + proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=socio_static_cache:10m max_size=2g inactive=60s use_temp_path=off; ## # Basic Settings @@ -50,9 +51,6 @@ 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/javascri> - - proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=momentsoflife_cache:10m max_size=1000m inactive=60s use_temp_path=off; - ## # Virtual Host Configs ## diff --git a/nginx/sites-available/socio.conf b/nginx/sites-available/socio.conf index c8f5479..57b479f 100644 --- a/nginx/sites-available/socio.conf +++ b/nginx/sites-available/socio.conf @@ -50,6 +50,9 @@ server { proxy_request_buffering off; location /api/v1/static/user-avatars/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; @@ -64,6 +67,9 @@ server { } location /api/v1/static/post-attachments/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; @@ -78,6 +84,9 @@ server { } location /api/v1/static/group-avatars/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; @@ -92,6 +101,9 @@ server { } location /api/v1/static/stickers/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; @@ -106,6 +118,9 @@ server { } location /api/v1/static/message-attachments/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; diff --git a/nginx/sites-enabled/socio.conf b/nginx/sites-enabled/socio.conf index 8a87a27..57b479f 100644 --- a/nginx/sites-enabled/socio.conf +++ b/nginx/sites-enabled/socio.conf @@ -40,7 +40,6 @@ server { ssl_certificate /etc/letsencrypt/fullchain.pem; ssl_certificate_key /etc/letsencrypt/privkey.pem; - add_header Alt-Svc 'h3=":443";max=86400'; # Allow special characters in headers ignore_invalid_headers off; # Allow any size file to be uploaded. @@ -51,6 +50,9 @@ server { proxy_request_buffering off; location /api/v1/static/user-avatars/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; @@ -65,6 +67,9 @@ server { } location /api/v1/static/post-attachments/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; @@ -79,12 +84,15 @@ server { } location /api/v1/static/group-avatars/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; proxy_set_header Connection ""; chunked_transfer_encoding off; -proxy_set_header Host $http_host; + proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; @@ -93,6 +101,9 @@ proxy_set_header Host $http_host; } location /api/v1/static/stickers/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1; @@ -107,6 +118,9 @@ proxy_set_header Host $http_host; } location /api/v1/static/message-attachments/ { + proxy_cache socio_static_cache; + proxy_cache_valid 200 60s; + proxy_connect_timeout 300; # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 proxy_http_version 1.1;