2

I am trying to set up a caching reverse proxy with 2 conditions; if either is met, it shouldn't be storing the file from origin:

  • partial-content request
  • request with query string

As configured below, I got nginx to NOT store partial-content requests.
However, it is still storing requests with query string. What am I missing here?

curl -r 1000-2000 http://edge.com/data/abcdef.dat [OK. No file stored.]
wget http://edge.com/data/abcdef.dat?query=string [Not OK. abcdef.dat stored on edge.]

location /data/ {
    set $originuri /origin$uri$is_args$args;
    errorpage 404 = $originuri;
}

location /origin/ {
    proxy_pass http://origin.com:1111;
    proxy_store /mnt1/edge/store;
    proxy_temp_path /mnt1/edge/tmp;
    proxy_set_header If-Range $http_if_range;
    proxy_set_header Range $http_range;
    proxy_no_cache $http_range $http_if_range $is_args;
}
0

If I'm reading your configuration right, when you pass the request to the origin location for proxying, you're building a URI string which doesn't include a GET query string (i.e. you're flattening the $args). If that's what's happening, it would explain why the origin location isn't seeing $is_args as true.

This is a hunch on my part - I'd want to look at the request logs to see if it's correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.