Welcome! Log In Create A New Profile

Advanced

X-Accel-Redirect, proxy_pass and Range Requests.

Ben Timby
October 06, 2010 11:34AM
I have some complex interaction going on here and I would like to see
if anybody has some suggestions for me.

I have Nginx in front of apache serving static files, performing
compression and SSL. For large files, I use X-Accel-Redirect header to
offload the sending to nginx. This all works beautifully.

However, the problem is that the backend tracks downloads, it only
allows a certain number of downloads per file. Some of these files are
PDFs that are opened on the client side using Acrobat Reader. Acrobat
Reader sends Range requests to nginx.

Nginx will then forward the range request to apache, which returns a
200 including the X-Accel-Redirect header. Nginx then pulls the
correct range from the indicated file and returns that to the client
with a 206 status.

The problem is, each of these range requests is counted by my backend
as a download, expiring the download counter prematurely.

My thought on a possible solution is to simply turn on caching in
nginx, allowing it to satisfy subsequent range requests without
hitting the backend. Something like the following:

proxy_cache "zone_name";
proxy_cache_key "$host$request_uri$cookie_sessionid";
proxy_cache_valid 206 1m;

However, I am curious if the proxy_cache_valid directive matches on
the response code of the backend, or the response code that nginx will
send to the client. Also, how does proxy_cache interact with
X-Accel-Redirect?

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

X-Accel-Redirect, proxy_pass and Range Requests.

Ben Timby October 06, 2010 11:34AM

Re: X-Accel-Redirect, proxy_pass and Range Requests.

Maxim Dounin October 06, 2010 12:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 315
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready