X-Accel-Buffering, proxy_buffering and proxy_store

Michał Jaszczyk jasiu85 at gmail.com
Mon Jan 5 15:08:16 MSK 2009

Hi everyone,

I'm trying to set up safe file downloading with Nginx. My config file
stripped down to most important elements looks like this:

    upstream tempurl {
        server tempurl:8888;
    upstream storage {
        server storage:8888;
    server {
        listen 8888;
        location / {
            proxy_pass http://tempurl;
        location /storage {
            root storage_cache;
            try_files $uri @storage;
        location @storage {
            rewrite ^/storage/(.*) /$1 break;
            proxy_pass http://storage;
            proxy_store storage_cache$uri;

The idea is that a user obtains somehow a temporary URL to a file and
asks my server for it. Then my server asks the "tempurl" server to
resolve it to real file name. The "tempurl" server returns
X-Accel-Redirect header with real path to the file. The file is
located on "storage" server, so we download it from there and
simultaneously mirror it by using try_files and proxy_store

My question is: The "tempurl" server can send X-Accel-Buffering header
and I can use proxy_buffering directive. How will these two interact
with proxy_store? I'd like to avoid unnecessary disk reads/writes and
avoid blocking worker by sending response to a user with slow
connection. Where should I use buffering and where shouldn't I in the
above situation?



More information about the nginx mailing list