Nginx proxy config problem

2 question:

  1. i want to put the pic,css,js etc. files on the frontend server, but
    with below config, i put a tar file to /var/www/a.com/test.tar and
    visite http://a.com/test.tar it return a 404 herder. how can i fix it?

  2. i want control the proxy cache for different cache time with the
    different request uri, could you give me the right way to config it ?
    thank you very much.

my nginx.conf

server {
listen 80;
root /var/www/a.com;
server_name a.com;
index index.html index.htm index.php;

location ^~ /admin/ {
    proxy_pass http://backend;
}

location ~* ^/post/ {
    proxy_cache             main;
    proxy_cache_valid       200 301 302 60d;
    proxy_cache_valid       any 30d;
    proxy_pass              http://backend;
}

location ~* ^/(list|archive)/ {
    proxy_cache             main;
    proxy_cache_valid       200 301 302 60d;
    proxy_cache_valid       any 1d;
    proxy_pass              http://backend;
}

location ~ ^.*\.php$ {
    proxy_pass http://backend;
}

location / {
    proxy_cache             main;
    proxy_cache_valid       any 10m;
    proxy_pass http://backend;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
    expires      30d;
}

}

Posted at Nginx Forum:

Hello

Am 24.05.2012 16:26 schrieb “21andy” [email protected]:

2 question:

  1. i want to put the pic,css,js etc. files on the frontend server, but
    with below config, i put a tar file to /var/www/a.com/test.tar and
    visite http://a.com/test.tar it return a 404 herder. how can i fix it?

Your static file regex doesn’t include .tar file.

index index.html index.htm index.php;
}
}

}

Posted at Nginx Forum:
nginx proxy config problem

i am sorry, i means i want :

if file exists on frontend server, then output it, don’t through
backend. not only tar file.

and make these uri for diffrent cache time:
/post/name/ cache 30 days
/list/name/ cache 1 day
/index.html cache 1 hour
other cache 10 minutes

how can i do this?

Posted at Nginx Forum:

On Thursday 24 May 2012 14:02:49 21andy wrote:

i am sorry, i means i want :

if file exists on frontend server, then output it, don’t through
backend. not only tar file.

The try_files directive should be useful for this task.
Take a look: Module ngx_http_core_module

wbr, Valentin V. Bartenev