Use nginx as proxy with cache for satic files
ice-egal at web.de
ice-egal at web.de
Sat Sep 5 00:14:40 MSD 2009
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
More information about the nginx
mailing list