27 lines
891 B
Nginx Configuration File
27 lines
891 B
Nginx Configuration File
http {
|
|
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=api_cache:10m max_size=1g inactive=365d;
|
|
server {
|
|
listen 3000;
|
|
location /health {
|
|
return 200 "healthy\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
location / {
|
|
proxy_cache api_cache;
|
|
proxy_cache_valid 200 365d;
|
|
# Only cache if X-Cache header is present
|
|
proxy_cache_bypass $http_x_cache_inverse;
|
|
proxy_no_cache $http_x_cache_inverse;
|
|
# Set inverse variable (cache disabled by default)
|
|
set $http_x_cache_inverse 1;
|
|
if ($http_x_cache) {
|
|
set $http_x_cache_inverse 0;
|
|
}
|
|
proxy_cache_key $scheme$proxy_host$uri$is_args$args;
|
|
proxy_pass $arg_url;
|
|
add_header X-Cache-Status $upstream_cache_status;
|
|
}
|
|
}
|
|
}
|