# Use 100 MiB cache with a 1 MiB memory zone (enough for ~8,000 keys).
# Delete data that has not been accessed for 10 minutes.
fastcgi_cache_path /var/cache/nginx/fediblock levels=1:2 max_size=100m
keys_zone=fediblock:1m inactive=10m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
add_header X-Cache $upstream_cache_status;
limit_req_zone $binary_remote_addr zone=fediblock_add:10m rate=1r/m;
server {
# […]
expires 30m;
location ~* "(png|jpe?g|webp|gif)$" {
expires 6d;
}
location /add {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/cgi-fcgiwrap.socket-1;
fastcgi_param SCRIPT_FILENAME /usr/bin/fediblock-backend;
fastcgi_param HOME "/var/lib/nginx"; # When I didn't set it, HOME was /root.
client_max_body_size 5M;
limit_req zone=fediblock_add;
}
location /rss {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/cgi-fcgiwrap.socket-1;
fastcgi_param SCRIPT_FILENAME /usr/bin/fediblock-backend-gen_rss;
fastcgi_param HOME "/var/lib/nginx";
fastcgi_cache fediblock;
fastcgi_cache_valid 200 15m; # Cache answers for up to 15 minutes.
fastcgi_cache_lock on; # Relay only one identical request at a time.
}
location /api/v1/list {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/cgi-fcgiwrap.socket-1;
fastcgi_param SCRIPT_FILENAME /usr/bin/fediblock-backend-json_api;
fastcgi_param HOME "/var/lib/nginx";
fastcgi_cache fediblock;
fastcgi_cache_valid 200 15m; # Cache answers for up to 15 minutes.
fastcgi_cache_lock on; # Relay only one identical request at a time.
}
}