nginx and proxy_cache does seem to be used

fredericsidler nginx-forum at nginx.us
Sat Aug 29 01:38:30 MSD 2009


I'm a scalr.net user. Scalr.net is a management system that sits on top of Amazon Web Services. It does use nginx as load balancer when you build a farm with app servers behind it. I was fine with it until I reached an important number of users.

So I looked for a solution to cache the requests. I first ugrade the original Ubuntu 8.04 with nginx 0.5.3 to the 0.6.38 version of nginx and I notice that proxy_store was not what I was looking for. Then I updated nginx to the 0.7.61 version and use proxy_cache. If I got it correctly it should do what squid or varnish can do. But it doesn't seem to work and I don't know how to verify it.

The configuration file that I put below is the original scalr configuration file with the adjustements I made for caching the contents (in red). First, could you tell me if nginx can handle what I'm looking for. Then, if the proxy_cache is the right way to go and why it doesn't seem it to work. Finally how I can be sure that the files stored under proxy_cache_path are used.

nginx.conf from scalr.net with adjustment in red for caching successfull requests for 3 hours.

user www-data;
worker_processes  4;

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;

events {
   worker_connections  4096;
}

http {
   include       /etc/nginx/mime.types;
   default_type  application/octet-stream;

   access_log  /var/log/nginx/access.log;

   sendfile        on;

   keepalive_timeout  30;
   tcp_nodelay        on;

   include /etc/nginx/app-servers.include;

   proxy_cache_path /var/www/fbcaldotcom/cache levels=1:2 keys_zone=one:10m;

   server {
       listen       80;

       if ( $remote_addr = 127.0.0.1 ) {
           rewrite   ^(.*)$  /500.html last;
           return 302;

       }

       location /    {
           proxy_pass         http://backend;

           proxy_redirect off;
           proxy_cache one;
           proxy_cache_valid 200 3h;

           proxy_buffering    on;

           proxy_set_header   Host             $host;
           proxy_set_header   X-Real-IP        $remote_addr;
           proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

           error_page   500 501  =  /500.html;
           error_page   502 503 504  =  /502.html;
       }

       location /500.html {
               root   /var/www/nginx-default;
       }

       location /502.html {
               root   /var/www/nginx-default;
       }

   }

}

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,5281,5281#msg-5281






More information about the nginx mailing list