Add CGI caching to nginx example.
This commit is contained in:
parent
e70e07c579
commit
e8c1dcdf2b
@ -1,39 +1,21 @@
|
||||
# Use 100 MiB cache with a 1 MiB memory zone (enough for ~8,000 keys).
|
||||
# Delete data that has not been accessed for 30 minutes.
|
||||
fastcgi_cache_path /var/cache/nginx/avatar levels=1:2 keys_zone=avatar:1m
|
||||
max_size=100m inactive=30m 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 avatar.example.com;
|
||||
|
||||
# access_log /var/log/nginx/avatar main;
|
||||
error_log /var/log/nginx/avatar warn;
|
||||
error_log /var/log/nginx/avatar_log warn;
|
||||
|
||||
ssl_certificate /var/lib/dehydrated/certs/avatar.example.com/fullchain.pem;
|
||||
ssl_certificate_key /var/lib/dehydrated/certs/avatar.example.com/privkey.pem;
|
||||
|
||||
# 86400 seconds = 1 day
|
||||
expires 86400;
|
||||
add_header Cache-Control "public, max-age=86400" always;
|
||||
|
||||
location / {
|
||||
include /etc/nginx/fastcgi_params;
|
||||
fastcgi_pass unix:/var/run/cgi-fcgiwrap.socket-1;
|
||||
fastcgi_param SCRIPT_FILENAME /usr/bin/libravatarserv;
|
||||
|
||||
# fastcgi_param LIBRAVATARSERV_DEFAULT_FALLBACK 404;
|
||||
# fastcgi_param LIBRAVATARSERV_REDIRECT_NOFALLBACK 0;
|
||||
# fastcgi_param LIBRAVATARSERV_REDIRECT_NOUSER 0;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name avatar.example.com;
|
||||
|
||||
# access_log /var/log/nginx/avatar main;
|
||||
error_log /var/log/nginx/avatar warn;
|
||||
|
||||
expires 86400;
|
||||
add_header Cache-Control "public, max-age=86400" always;
|
||||
expires 6h;
|
||||
|
||||
location / {
|
||||
include /etc/nginx/fastcgi_params;
|
||||
@ -43,5 +25,9 @@ server {
|
||||
# fastcgi_param LIBRAVATARSERV_DEFAULT_FALLBACK 404;
|
||||
# fastcgi_param LIBRAVATARSERV_REDIRECT_NOFALLBACK 0;
|
||||
# fastcgi_param LIBRAVATARSERV_REDIRECT_NOUSER 0;
|
||||
|
||||
fastcgi_cache avatar;
|
||||
fastcgi_cache_valid 200 2h; # Cache answers for up to 2 hours.
|
||||
fastcgi_cache_lock on; # Relay only one identical request at a time.
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user