Problems getting NginX to cache

Folks,

I’ve been trying to setup NginX as a frontend cache for a webserver.
This is rather challenging, as the documentation is a little flakey but
it does look like it should be fairly straight forward. The reverse
proxing is working just fine, it just doesn’t cache anything. This is
on version nginx version: nginx/0.7.65

I have added the following to the http {} section:

proxy_buffering           on;
proxy_cache_valid         any 10m;
proxy_cache_path  /var/www/cache levels=1:2 keys_zone=my-cache:8m

max_size=1000m inactive=600m;
proxy_temp_path /var/www/tmp;
proxy_buffer_size 4k;
proxy_buffers 100 8k;

The following to server {}:

proxy_buffering on;
proxy_store          on;
proxy_store_access   user:rw  group:rw  all:r;
proxy_set_header  X-Real-IP  $remote_addr;
proxy_set_header  Host       $host;

And the following to location {}:

proxy_cache            my-cache;
proxy_cache_valid       200;

I have enabled debugging and have a lot of logs. The relivant section
appears to be:

2010/03/26 17:20:45 [debug] 22172#0: *163 copy filter: “/?”
2010/03/26 17:20:45 [debug] 22172#0: *163 http postpone filter “/?”
00000000006C7408
2010/03/26 17:20:45 [debug] 22172#0: *163 write old buf t:1 f:0
00000000006C7138, pos 00000000006C7138, size: 279 file: 0, size: 0
2010/03/26 17:20:45 [debug] 22172#0: *163 write new buf t:0 f:1
00000000006C7870, pos 00000000006C79D6, size: 1300 file: 358, size: 1300
2010/03/26 17:20:45 [debug] 22172#0: *163 http write filter: l:0 f:0
s:1579
2010/03/26 17:20:45 [debug] 22172#0: *163 http write filter limit 0
2010/03/26 17:20:45 [debug] 22172#0: *163 writev: 279
2010/03/26 17:20:45 [debug] 22172#0: *163 sendfile: @358 1300
2010/03/26 17:20:45 [debug] 22172#0: *163 sendfile: 1300, @358 1300:1300
2010/03/26 17:20:45 [debug] 22172#0: *163 http write filter
0000000000000000
2010/03/26 17:20:45 [debug] 22172#0: *163 copy filter: 0 “/?”
2010/03/26 17:20:45 [debug] 22172#0: *163 pipe write downstream done
2010/03/26 17:20:45 [debug] 22172#0: *163 event timer: 13, old:
1269624105234, new: 1269624105236
2010/03/26 17:20:45 [debug] 22172#0: *163 http file cache update
2010/03/26 17:20:45 [debug] 22172#0: *163 http file cache rename:
“/var/www/tmp/0000000081” to
“/var/www/cache/8/ac/3577c9b1c200387b980a8810e0b67ac8”
2010/03/26 17:20:45 [crit] 22172#0: *163 chmod()
“/var/www/tmp/0000000081” failed (2: No such file or directory) while
reading upstream, client: 1.1.1.1, server: www.example.net,
request: “GET / HTTP/1.1”, upstream: “http://1.2.3.4:80/”, host:
www.exmaple.net:80
2010/03/26 17:20:45 [crit] 22172#0: *163 unlink()
“/var/www/tmp/0000000081” failed (2: No such file or directory) while
reading upstream, client: 1.1.1.1, server: www.example.net,
request: “GET / HTTP/1.1”, upstream: “http://1.2.3.4:80/”, host:
www.exmaple.net:80
2010/03/26 17:20:45 [debug] 22172#0: *163 http upstream exit:
0000000000000000
2010/03/26 17:20:45 [debug] 22172#0: *163 finalize http upstream
request: 0
2010/03/26 17:20:45 [debug] 22172#0: *163 finalize http proxy request
2010/03/26 17:20:45 [debug] 22172#0: *163 free rr peer 1 0

So it seems it can’t chmod or ulink the file cause it’s not there.
There’s no indication of why this might be. Nginx quite happilly
creates the proxy tmp directory but doesn’t appear to put anything in
it. Even though the debug suggests that it thinks that is has.

Does anyone have any idea what is going on?

I’ve only seen on similar occurance of this on the Russian list but this
was in Russian :slight_smile: Google translate suggested that they didn’t really
bottom it out.

Mike.

On Sat, Mar 27, 2010 at 12:40:28PM +0000, Mike wrote:

Folks,

I’ve been trying to setup NginX as a frontend cache for a webserver.
This is rather challenging, as the documentation is a little flakey but
it does look like it should be fairly straight forward. The reverse
proxing is working just fine, it just doesn’t cache anything. This is
on version nginx version: nginx/0.7.65

Seems that the solution to this was to comment out the following two
lines:

#proxy_store on;
#proxy_store_access user:rw group:rw all:r;

Or rather, to turn proxy_store off. The cache appears to be caching
quite happilly now.

Mike.

Hello!

On Sat, Mar 27, 2010 at 12:40:28PM +0000, Mike wrote:

I’ve been trying to setup NginX as a frontend cache for a webserver.
This is rather challenging, as the documentation is a little flakey but
it does look like it should be fairly straight forward. The reverse
proxing is working just fine, it just doesn’t cache anything. This is
on version nginx version: nginx/0.7.65

[…]

proxy_cache            my-cache;
proxy_cache_valid       200;

[…]

Directives proxy_store and proxy_cache can’t be used at the same
time, while in your config proxy_store is inherited from server
level - so effectively you have both of them switched on in the
location.

It’s the bug that nginx doesn’t reject such configuration as
invalid.

Adding “proxy_store off;” to your location with proxy_cache (or
just removing it from server block) will resolve your problem.

Maxim D.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs