Add caching to nginx example.

This commit is contained in:
tastytea 2020-10-24 20:30:46 +02:00
parent 8574da33a7
commit 15ee493084
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 14 additions and 5 deletions

View File

@ -1,25 +1,34 @@
# RSS feeds will be available at <https://rss.example.com/?repo=user/project>.
# 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/gitea2rss levels=1:2 keys_zone=gitea2rss:1m
max_size=100m inactive=10m use_temp_path=off;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
add_header X-Cache $upstream_cache_status;
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name rss.example.com;
#access_log /var/log/nginx/rss.access_log main;
error_log /var/log/nginx/rss.error_log warn;
error_log /var/log/nginx/rss.example.com_log warn;
ssl_certificate /var/lib/dehydrated/certs/rss.example.com/fullchain.pem;
ssl_certificate_key /var/lib/dehydrated/certs/rss.example.com/privkey.pem;
# Tell clients to cache for 1 hour.
expires 1h;
# Tell clients to cache for 30 minutes.
expires 30m;
location / {
include /etc/nginx/fastcgi_params;
# You may need to change fastcgi_pass.
fastcgi_pass unix:/var/run/cgi-fcgiwrap.socket-1;
fastcgi_param SCRIPT_FILENAME /usr/bin/gitea2rss;
# Base URL of your Gitea instance.
fastcgi_param GITEA2RSS_BASEURL "https://git.example.com";
fastcgi_cache gitea2rss;
fastcgi_cache_valid 200 20m; # Cache answers for up to 20 minutes.
fastcgi_cache_lock on; # Relay only one identical request at a time.
}
}