cache optymalisation
This commit is contained in:
parent
2b99559d2b
commit
51cb8238f4
|
|
@ -10,7 +10,7 @@ services:
|
||||||
TZ: Europe/Warsaw
|
TZ: Europe/Warsaw
|
||||||
NGINX_ENVSUBST_TEMPLATE_DIR: /etc/nginx/templates
|
NGINX_ENVSUBST_TEMPLATE_DIR: /etc/nginx/templates
|
||||||
NGINX_ENVSUBST_OUTPUT_DIR: /etc/nginx/conf.d
|
NGINX_ENVSUBST_OUTPUT_DIR: /etc/nginx/conf.d
|
||||||
NGINX_CACHE_DISK_PATH: "/var/cache/nginx"
|
|
||||||
|
|
||||||
ports:
|
ports:
|
||||||
- "80:80"
|
- "80:80"
|
||||||
|
|
@ -19,8 +19,8 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
# Konfiguracja Nginx
|
# Konfiguracja Nginx
|
||||||
- apps-data:/etc/nginx/conf.d:ro
|
- apps-data:/etc/nginx/conf.d:ro
|
||||||
- nginx2GB_cache:/var/cache/nginx2GB
|
- nginx_cache:/var/cache/nginx_cache
|
||||||
- nginx05GB_cache:/var/cache/nginx05GB
|
|
||||||
|
|
||||||
# Certyfikaty SSL
|
# Certyfikaty SSL
|
||||||
- ${DOCKER_DATA}/letsencrypt:/letsencrypt:rw
|
- ${DOCKER_DATA}/letsencrypt:/letsencrypt:rw
|
||||||
|
|
@ -28,22 +28,16 @@ services:
|
||||||
|
|
||||||
- ${DOCKER_DATA}/nginx-logs:/var/log/nginx:rw
|
- ${DOCKER_DATA}/nginx-logs:/var/log/nginx:rw
|
||||||
|
|
||||||
command: /bin/sh -c "mkdir -p /var/cache/nginx05GB /var/cache/nginx2GB && nginx -g 'daemon off;'"
|
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
nginx2GB_cache:
|
nginx_cache:
|
||||||
driver_opts:
|
driver_opts:
|
||||||
type: tmpfs
|
type: tmpfs
|
||||||
device: tmpfs
|
device: tmpfs
|
||||||
o: size=2147483648 # 2GB
|
o: size=3G
|
||||||
nginx05GB_cache:
|
|
||||||
driver_opts:
|
apps-data:
|
||||||
type: tmpfs
|
external: true
|
||||||
device: tmpfs
|
|
||||||
o: size=536870912 # 512MB
|
|
||||||
apps-data:
|
|
||||||
external: true
|
|
||||||
|
|
||||||
networks:
|
networks:
|
||||||
proxy-net:
|
proxy-net:
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,17 @@
|
||||||
# Limitowanie requestów (pozostawiamy bez zmian)
|
# Limitowanie requestów (pozostawiamy bez zmian)
|
||||||
limit_req_zone $binary_remote_addr zone=ip_limit:10m rate=30r/s;
|
limit_req_zone $binary_remote_addr zone=ip_limit:10m rate=30r/s;
|
||||||
|
|
||||||
# Konfiguracja cache (nowa część)
|
proxy_cache_path /var/cache/nginx
|
||||||
proxy_cache_path /var/cache/nginx05GB levels=1:2 keys_zone=STATIC:50m inactive=24h max_size=500m use_temp_path=off;
|
|
||||||
|
|
||||||
proxy_cache_path /var/cache/nginx2GB
|
|
||||||
levels=1:2
|
levels=1:2
|
||||||
keys_zone=GLOBAL_CACHE:256m
|
keys_zone=COMBINED_CACHE:320m # 256m + 64m
|
||||||
inactive=7d
|
inactive=7d
|
||||||
max_size=2g
|
max_size=2500m # Zostawiamy margines
|
||||||
use_temp_path=off
|
use_temp_path=off
|
||||||
manager_files=0 # Wyłącza logi manager-a
|
manager_files=0
|
||||||
loader_files=0 # Wyłącza logi loader-a
|
loader_files=0
|
||||||
loader_threshold=300
|
loader_threshold=300
|
||||||
loader_sleep=50;
|
loader_sleep=50;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 443 ssl;
|
listen 443 ssl;
|
||||||
server_name www.bodypainter.eu;
|
server_name www.bodypainter.eu;
|
||||||
|
|
@ -53,7 +50,7 @@
|
||||||
location ~* \.(jpg|jpeg|png|gif|ico|webp|svg)$ {
|
location ~* \.(jpg|jpeg|png|gif|ico|webp|svg)$ {
|
||||||
access_log off;
|
access_log off;
|
||||||
proxy_pass http://arti24-container:3000;
|
proxy_pass http://arti24-container:3000;
|
||||||
proxy_cache GLOBAL_CACHE;
|
proxy_cache COMBINED_CACHE;
|
||||||
proxy_cache_valid 200 30d;
|
proxy_cache_valid 200 30d;
|
||||||
proxy_cache_min_uses 2;
|
proxy_cache_min_uses 2;
|
||||||
proxy_cache_lock on;
|
proxy_cache_lock on;
|
||||||
|
|
@ -73,6 +70,8 @@
|
||||||
|
|
||||||
expires 1y;
|
expires 1y;
|
||||||
access_log off;
|
access_log off;
|
||||||
|
proxy_cache_revalidate on; # Dodaj dla świeżości danych
|
||||||
|
proxy_cache_background_update on; # Lepsza wydajność
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue