nginx as a caching reverse proxy to replace squid/varnish

Mirosław Jaworski mjaw at ikp.pl
Tue Aug 18 11:53:41 MSD 2009


On Mon, 2009-08-17 at 14:39 -0700, mobiledreamers at gmail.com wrote:
> Hey guys 
> the following is our current setup on the apps
> 
> 
> but we would like to add nginx as a reverse proxy cache much like
> squid or varnish
> is it possible to edit this config to enable that caching behavior or
> do i need to add another nginx in front of this set up like i would do
> for squid or varnish
> 
> 
> if this can be done without resorting to usage of squid and varnish it
> would be nice to have the complete setup in nginx

http {
    [...]

    proxy_cache_path /opt/nginx/cache levels=1:2 keys_zone=one:10m;

    [...]

        server {
        listen       127.0.0.1:8000;
        server_name  localhost;
        access_log  /var/log/nginx/one.access.log  main;
        location / {
            proxy_pass         http://192.168.10.10:80/;
            proxy_redirect     off;

            proxy_cache        one;
            proxy_cache_valid  200 1h;
            [...]
        }
    }

Declaring cache ( proxy_cache_path ) and caching ( proxy_cache ) should
be enough.

Proxy_cache_valid in above example is used to enforce caching for
objects that have no declaration on caching.

-- 
Mirosław "Psyborg" Jaworski
GCS/IT d- s+:+ a C++$ UBI++++$ P+++$ L- E--- W++(+++)$ N++ o+ K- w-- O-
M- V- PS+ PE++ Y+ PGP t 5? X+ R++ !tv b++(+++) DI++ D+ G e* h++ r+++ y?
  "I don't care to belong to a club that accepts people like me as members."






More information about the nginx mailing list