# Nginx proxy config problem

**URL:** <https://www.ruby-forum.com/t/nginx-proxy-config-problem/219995>\
**Category:** NGINX\
**Created:** [May 24, 2012, 11:27am UTC](https://www.ruby-forum.com/t/nginx-proxy-config-problem/219995 "2012-05-24T11:27:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 24, 2012, 11:27am UTC](https://www.ruby-forum.com/t/nginx-proxy-config-problem/219995/1 "2012-05-24T11:27:49Z")

</div>

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](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](http://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:

> **[nginx proxy config problem](https://forum.nginx.org/read.php?2,226787,226787#msg-226787)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![21andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/2/aca169/32.png) [@21andy](https://www.ruby-forum.com/u/21andy)\
**Post date:** [May 24, 2012, 11:35am UTC](https://www.ruby-forum.com/t/nginx-proxy-config-problem/219995/2 "2012-05-24T11:35:53Z")

</div>

Hello

Am 24.05.2012 16:26 schrieb “21andy” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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](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:  
> [http://forum.nginx.org/read.php?2,226787,226787#msg-226787](http://forum.nginx.org/read.php?2,226787,226787#msg-226787)

---

<div class="post-metadata">

**Author:** ![21andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/2/aca169/32.png) [@21andy](https://www.ruby-forum.com/u/21andy)\
**Post date:** [May 24, 2012, 12:03pm UTC](https://www.ruby-forum.com/t/nginx-proxy-config-problem/219995/3 "2012-05-24T12:03:54Z")

</div>

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:

> **[Re: nginx proxy config problem](https://forum.nginx.org/read.php?2,226787,226789#msg-226789)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![21andy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/2/aca169/32.png) [@21andy](https://www.ruby-forum.com/u/21andy)\
**Post date:** [May 24, 2012, 1:27pm UTC](https://www.ruby-forum.com/t/nginx-proxy-config-problem/219995/4 "2012-05-24T13:27:17Z")

</div>

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](http://nginx.org/r/try_files)

wbr, Valentin V. Bartenev
