Update nginx config example.

* Add rate limiting.
* Add API endpoint.
This commit is contained in:
tastytea 2021-01-09 14:40:07 +01:00
parent c9002f3640
commit c7943d88d0
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 15 additions and 0 deletions

View File

@ -36,6 +36,8 @@ fastcgi_cache_path /var/cache/nginx/fediblock levels=1:2 max_size=100m
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 {
# […]
@ -50,6 +52,9 @@ server {
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 {
@ -61,6 +66,16 @@ server {
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.
}
}
--------------------------------------------------------------------------------