Where should I put proxy_cache?
The error:
nginx: [emerg] "proxy_cache" directive is not allowed here in /www/wwwroot/mysite.com/includes/nginx/customconfig.conf:34
nginx: configuration file /www/server/nginx/conf/nginx.conf test failed
The code:
map $request_uri $cache {
~*\.(ts|m4s|m4a|mp4)$ 1;
"~*fplsegment\.ts" 1;
"~*chunk-stream" 1;
}
server {
location ^~ /custom/ {
...
proxy_pass https://external.com/;
...
if ($cache) {
proxy_cache cache_one;
proxy_cache_key $cache;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 404 1m;
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
add_header X-Cache-Status $upstream_cache_status;
}
}
}