nginx support for http/1.1 backend

Ryan Malayter malayter at
Tue Oct 19 17:04:04 MSD 2010

On Tue, Oct 19, 2010 at 6:54 AM, Splitice <mat999 at> wrote:
> Seconded. Also the ability to cache gzip is a must

This can be done in nginx now by "layering" two nginx server blocks
together. The "front" one implements proxy_cache, while the back one
does compression and talks to the origin server. You get twice the
number of connections when you're actually talking to a back-end, but
if your cache hit ratio is high, that shouldn't matter and the
connections are very short-lived.

You should also "normalize" the incoming accept-encoding headers to
either "gzip" or "", and use that as part of the proxy cache key.

Something like this (untested syntax):

#frontend configuration which talks to client and caches
server {
  listen 80
  set $myacceptencoding "";
  if ($http_accept_encoding *~ "gzip") {
    set $myacceptencoding "gzip";
  location / {
  proxy_set_header "Accept-Encoding" $myacceptencoding;
  proxy_cache my_cache_zone_name;
  proxy_cache_key "$scheme$host$request_uri$myacceptencoding"
#backend server block which talks to origin and compresses
server {
  listen 10080
  gzip on;
  gzip_http_version 1.0;
  gzip_proxied any;
  gzip_types text/css text/javascript text/xml application/x-javascript;
  location / {
  proxy_pass http://realbackend


More information about the nginx mailing list