I'm using using Nginx as Reverse Proxy and Caching the proxied response from my upstream server.
So, I need to add a Content-Length header to this cached files before sending to my client.
I've tried adding the $upstream_response_length variable to location directive, but it doesn't work.
location /files/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_buffering on;
chunked_transfer_encoding off;
##PROXY CACHE CONFIG
proxy_cache my_cache;
add_header X-Proxy-Cache $upstream_cache_status;
proxy_ignore_headers Cache-Control;
proxy_cache_valid any 30m;
add_header Content-Length $upstream_response_length;
proxy_pass http://upstream_server;
}
How can I do this?