Welcome! Log In Create A New Profile


nginx and proxy_cache does seem to be used

August 28, 2009 05:38PM
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;

[color=#FF0000]proxy_cache_path /var/www/fbcaldotcom/cache levels=1:2 keys_zone=one:10m;[/color]

server {
listen 80;

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


location / {
proxy_pass http://backend;

[color=#FF0000]proxy_redirect off;
proxy_cache one;
proxy_cache_valid 200 3h;[/color]

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;


Subject Author Posted

nginx and proxy_cache does seem to be used

fredericsidler August 28, 2009 05:38PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 50
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready