Welcome! Log In Create A New Profile

Advanced

Use nginx as proxy with cache for satic files

Anonymous User
September 04, 2009 04:40PM
Hi,

I want to use nginx as a reverse proxy to my backend server with a cache
for the static files.
Proxy and cache work perfectly, when I do it like this:

location / {
proxy_pass http://backend.server.org/;
proxy_cache cache;
proxy_cache_valid 200 10m;
}


However I don't want to cache all the requests, only the requests on my
images folder.
So I tried this:

location / {
proxy_pass http://backend.server.org/;
}
location /images/ {
proxy_cache cache;
proxy_cache_valid 200 10m;
}

But now the image requests don't go through the proxy anymore, resulting
in a 404 error. Is there any way to inherit the proxy settings from the
parent folder/a certain location?
Of course I could just add the proxy settings to the "location /images/"
block, but the images folder is not the only one I want to be cached, so
there has to be an easier way to do this.

In other words: I want all requests going through the proxy, but keep a
cache of ceartain folders on the nginx server. What is the best way to
do so?

Thanks for reading, I hope someone is able to help me.

Regards
Alfred
Subject Author Posted

Use nginx as proxy with cache for satic files

Anonymous User September 04, 2009 04:40PM

Re: Use nginx as proxy with cache for satic files

Marcus Clyne September 04, 2009 06:08PM

Re: Use nginx as proxy with cache for satic files

Anonymous User September 05, 2009 06:24AM

Re: Use nginx as proxy with cache for satic files

Marcus Clyne September 05, 2009 08:30AM

Re: Use nginx as proxy with cache for satic files

Igor Sysoev September 05, 2009 08:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 185
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready