Page MenuHomeSealhub

fasada.conf.j2
No OneTemporary

Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None

fasada.conf.j2

# /etc/nginx/conf.d/reverse-proxy.conf
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=MICROCACHE:10m
max_size=100m inactive=1m use_temp_path=off;
limit_req_zone $binary_remote_addr zone=MICRORATE{{nginx_fasada_domain}}:10m rate=20r/s;
{% for path in nginx_fasada_strongly_cached_paths %}
proxy_cache_path /var/cache/nginx/{{nginx_fasada_site_name}}/{{path.cache_name}}
levels=1:2
keys_zone={{nginx_fasada_site_name}}__{{path.cache_name}}:500m
max_size={{path.max_cache_size}}
inactive=90d
use_temp_path=off;
{% endfor %}
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
keepalive_timeout 30;
keepalive_requests 1000;
server_name {{ nginx_fasada_domain }};
# SSL config (replace with your certs)
ssl_certificate /etc/letsencrypt/live/{{nginx_fasada_domain}}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{nginx_fasada_domain}}/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# Security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
open_file_cache max=5000 inactive=30s;
open_file_cache_valid 60s;
open_file_cache_min_uses 2;
open_file_cache_errors on;
# Enable gzip compression
gzip on;
gzip_vary on; # Add Vary: Accept-Encoding header
gzip_proxied any; # Enable gzip for all proxied requests
gzip_comp_level 4; # Compression level (1-9)
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_min_length 256; # Minimum response size to compress
gzip_disable "msie6"; # Disable gzip for old IE
# Microcache logic
proxy_cache MICROCACHE;
proxy_cache_valid 200 302 10s;
proxy_cache_valid 404 1s;
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
# by default it uses proxy_host instead of host which breaks
# multidomain functionality of the target as cached result from
# one domain is returned when requesting another domain
proxy_cache_key "$scheme$request_method$host$request_uri";
# Disable cache if any cookie is present
proxy_no_cache $http_cookie;
# Bypass cache if there is any cookie
set $no_cache 0;
if ($http_cookie) {
set $no_cache 1;
}
proxy_cache_bypass $no_cache;
proxy_no_cache $no_cache;
client_max_body_size {{ nginx_fasada_max_upload_size }};
{% for path in nginx_fasada_strongly_cached_paths %}
location {{path.url}} {
# Cache transformed images
proxy_cache {{nginx_fasada_site_name}}__{{path.cache_name}};
# Cache key must include resize args
proxy_cache_key "$scheme$request_method$host$request_uri";
# Cache successful responses
proxy_cache_valid 200 301 302 365d;
# Serve stale if backend struggling
proxy_cache_use_stale error timeout invalid_header updating http_500 http_502 http_503 http_504;
# Prevent stampede
proxy_cache_lock on;
proxy_cache_lock_timeout 10s;
proxy_cache_revalidate on;
# Debug headers
add_header X-Cache-Status $upstream_cache_status always;
# Long browser cache
expires 365d;
add_header Cache-Control "public, immutable";
# FORCE cache even if cookies exist
proxy_no_cache 0;
proxy_cache_bypass 0;
# Optional
access_log off;
log_not_found off;
include sites-enabled/{{ nginx_fasada_site_name }}-proxy-common.snip;
}
{% endfor %}
{% for static in nginx_fasada_static_dirs %}
location {{ static.url }}/ {
# Serve static files directly if you have them locally
alias {{ static.path }}/;
# Mark as public so browsers/CDNs can cache too
add_header Cache-Control "public, max-age=31536000, immutable";
add_header X-Cache-Status $upstream_cache_status;
sendfile on;
tcp_nopush on;
}
{% endfor %}
{% for nocache_path in nginx_fasada_never_cache %}
location ^~ {{nocache_path}} {
include sites-enabled/{{ nginx_fasada_site_name }}-proxy-common.snip;
# never cache admin pages in browser
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0" always;
proxy_no_cache 1;
proxy_cache_bypass 1;
limit_req zone=MICRORATEaspazja.pl burst=40 nodelay;
proxy_set_header Accept-Encoding "";
add_header X-Cache-Status $upstream_cache_status always;
}
{% endfor %}
location / {
include sites-enabled/{{ nginx_fasada_site_name }}-proxy-common.snip;
# Add headers to show caching info
add_header X-Cache-Status $upstream_cache_status always;
proxy_cache_background_update on;
proxy_cache_revalidate on;
tcp_nodelay on;
# mark HTML responses cacheable in browser for 5 mins
add_header Cache-Control "public, max-age=300" always;
# Rate limiting
limit_req zone=MICRORATE{{nginx_fasada_domain}} burst=40 nodelay;
# Enable compression for proxied responses
proxy_set_header Accept-Encoding ""; # Let Nginx handle compression
}
}

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 27, 17:06 (1 d, 21 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1229181
Default Alt Text
fasada.conf.j2 (5 KB)

Event Timeline