Issues about nginx proxy_cache

Hi:
Dear all
It is very pleasure to join in nginx mail list, but exactly i met a
problem When I use nginx1.7.9 as a reverse-proxy-server. more details
as follows:
my design requirements are those:
what I want is that nginx download the files to local by parsing
response-http-302-code .
But Unfortunately , nginx transmit the 302-redirect-link to my
browser directly. When my browser receive the response,it download files
from redirected-link.
So means that It doesn’t via nginx when download the video-file.

for example:

my-browser ----------> Server-A(nginx)---------->Server-B(Server local
file) Server-C(Server has video-file)
|<-------302+C-addr-------| <--------302 C-addr--------|
|----------------------request video
file------------------------------------------------->|

<-----------------------200 OK video file

What my problem is Server-A dosen’t cache the video file.
I try to these two cache strategies as follows,but nothing effects,how
can I fix it.

First I use proxy_store nginx.conf as follows :

events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
server {
listen 8065;
server_name localhost;
location / {
expires 3d;
proxy_set_header Accept-Encoding ‘’;
root /home/mpeg/nginx;
proxy_store on;
proxy_store_access user:rw group:rw all:rw;
proxy_temp_path /home/mpeg/nginx;
if ( !-e $request_filename) {
proxy_pass http://172.30.25.246:8099;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}

And then I use proxy_cache,nginx.conf as follows

events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
client_body_buffer_size 512k;
proxy_connect_timeout 10;
proxy_read_timeout 180;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_temp_path /home/mpeg/cache/temp;
proxy_cache_path /home/mpeg/cache levels=1:2 keys_zone=content:20m
inactive=1d max_size=100m;
server {
listen 8064;
server_name localhost;
location / {
proxy_cache content;
proxy_cache_valid 200 302 24h;
proxy_cache_valid any 1d;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache_key $host$uri$is_args$args;
proxy_pass http://192.168.15.159:7090;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}

}

If you access it correctly, nginx will send the request to backend and
pass
response which is 302-redirect-link in your case back to the browser.

Check the “302-redirect-link”, I think it should be an address to
http://192.168.15.159:7090 not to nginx(port 8064/8065), that’s why the
browser bypasses nginx.

Also note, proxy_store does nothing to the stored file, it’s quite
different from proxy_cache.

On Friday 15 May 2015 16:38:36 紫凌之魂 wrote:

Hi:
Dear all
It is very pleasure to join in nginx mail list, but exactly i met a problem
When I use nginx1.7.9 as a reverse-proxy-server. more details as follows:
my design requirements are those:
what I want is that nginx download the files to local by parsing
response-http-302-code .

You should use X-Accel-Redirect instead. See:

wbr, Valentin V. Bartenev