Skip to content

Commit

Permalink
general: add static caching for minio images
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrMitin committed May 27, 2024
1 parent e67055c commit 4e3937c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
4 changes: 1 addition & 3 deletions nginx/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
##
Expand Down
15 changes: 15 additions & 0 deletions nginx/sites-available/socio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
18 changes: 16 additions & 2 deletions nginx/sites-enabled/socio.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 4e3937c

Please sign in to comment.