title: Nginx image_filter
body: <p>I store static on S3 and use <a href="http://nginx.org/en/" rel="nofollow" title="nginx">nginx</a> as front-end. For fetch from S3 I use this construction:</p>
  
  <pre><code>location / {
      try_files $uri @s3;
  }
  
  location @s3 {
      root /var/www/static.dev;
      proxy_pass https://bucket.s3-eu-west-1.amazonaws.com;
      proxy_store off; # for test purposes
      proxy_store_access all:rw;
      proxy_temp_path /dev/shm;
  }
  </code></pre>
  
  <p>This work!
  But I want to generate thumbs and use this location:</p>
  
  <pre><code>if ( $uri ~ ^/t/ ) {
      set $w 182;
      set $h 114;
  }
  if ( $uri ~ ^/m/ ) {
      set $w 640;
      set $h 1280;
  }
  if ( $uri ~ ^/l/ ) {
      set $w 1024;
      set $h 2048;
  }
  
  location ~ ^/(?:t|m|l)/(.*\.(?:jpg|gif|png))$ {
      rewrite ^/[t|m|l]+/(.*)$ /$1;
      image_filter crop $w $h;
  }
  </code></pre>
  
  <p>But this not work, nginx return <code>415 Unsupported Media Type</code>.
  What wrong?</p>