refactor: usa snippets para acme e cache params

This commit is contained in:
João Pedro Toledo Goncalves 2026-01-30 12:12:34 -03:00
parent 91ee957ba7
commit c4bf1050b7
4 changed files with 12 additions and 9 deletions

View File

@ -29,9 +29,7 @@ server {
server_name ferreirareal.com.br www.ferreirareal.com.br;
# Permite a renovação de certificado Let's Encrypt.
location /.well-known/acme-challenge/ {
root /var/www/html; # Ajuste este caminho se necessário.
}
include snippets/acme_challenge.conf;
# Redireciona todo o resto para a versão segura e canônica.
location / {
@ -122,11 +120,8 @@ server {
# --- Estratégia de Cache (IMPORTANTE) ---
# Lembre-se de adicionar a linha 'proxy_cache_path' correspondente em nginx.conf!
proxy_cache ferreirareal_cache; # Nome de cache exclusivo para este site.
proxy_cache_revalidate on;
proxy_cache_lock on;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
add_header X-Proxy-Cache $upstream_cache_status; # Mostra se o cache foi HIT, MISS, etc.
proxy_cache ferreirareal_cache;
include snippets/cache_proxy_params.conf;
# --- REGRAS DE ROTEAMENTO (LOCATIONS) ---

View File

@ -2,7 +2,7 @@
# Include this in port 80 server blocks to allow Certbot validation
location ^~ /.well-known/acme-challenge/ {
root /var/www/certbot;
root /var/www/html;
try_files $uri =404;
allow all;
auth_basic off;

View File

@ -0,0 +1,7 @@
# Standard Proxy Cache Settings
# Include this inside server blocks that use proxy_cache
proxy_cache_revalidate on;
proxy_cache_lock on;
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
add_header X-Proxy-Cache $upstream_cache_status;

View File

@ -1,6 +1,7 @@
# Dynamic Shared Cache Zone
# Single zone for all sites, separating content by Host + URI
proxy_cache_path /var/cache/nginx/dynamic_cache levels=1:2 keys_zone=dynamic_cache:50m max_size=10g inactive=7d use_temp_path=off;
proxy_cache_path /var/cache/nginx/ferreirareal levels=1:2 keys_zone=ferreirareal_cache:10m max_size=1g inactive=7d use_temp_path=off;
# Default Cache Key (ensure uniqueness per host)
proxy_cache_key "$scheme$request_method$host$request_uri";