Page MenuHomeSealhub

fasada.conf.j2
No OneTemporary

Authored By
Unknown
Size
4 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=100r/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;
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;
# 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 5; # 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$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 "$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;
# 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;
}
{% 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;
# 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:19 (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1229212
Default Alt Text
fasada.conf.j2 (4 KB)

Event Timeline