New NGINX Proxy Filter Features and Example Usage

May 31st, 2009

There are some very nice new NGINX features now available - and the 0.7.x branch has been marked stable!

Here's the scoop on the new features:

  • there is a new image filter which is powered by libgd
  • the proxy server now includes a cache

This is terrific news in my opinion. NGINX is really becoming an excellent filtering proxy with the help of the existing XSLT transformer. One thing I'm hoping to see soon is a Markdown filter. That would be sweet.

It took me a moment to figure out how to use the proxy_cache, so here's and example. In the http configuration section:

http {    include       /etc/nginx/mime.types;    default_type  application/octet-stream;    server_names_hash_bucket_size 128;    access_log  /var/log/nginx/access.log;    large_client_header_buffers 4 16k;    proxy_buffer_size 16k;    proxy_buffers 8 16k;    proxy_busy_buffers_size 32k;    proxy_intercept_errors on;    proxy_cache_path  /var/lib/nginx/cache  levels=1:2   keys_zone=one:1m;    proxy_cache_valid  200 302  10m;}

The proxy_cache_path has to be on the same partition as the proxy_temp_path, and on debian, that is /var/lib/nginx/proxy.

So that's just the base configuration. To have something get cached, I used the proxy_cache setting in a location directive:

    location /proxyme {        default_type image/jpeg;        image_filter_jpeg_quality 70;        image_filter   resize  100 100;        proxy_pass;        proxy_cache one;    }

That's also an example of how to use the image_filter module. I tried using variables for the resize parameters, but that didn't work. The resize feature keeps the scale of the original image, which is great.

Yearly Indexes: 2003 2004 2006 2007 2008 2009 2010 2011 2012 2013 2015 2019 2020 2022