Issue with image resizing

Benyamin Dvoskin benyamin.dvoskin at
Mon Feb 6 16:00:03 UTC 2017


I'm trying to implement live image resizing on nginx using
ngx_http_image_filter_module, and I get some weird issues with it.

this is my config for resizing:

server {
   listen 1111;
   server_name localhost;
   set $backend '';
   resolver_timeout 5s;
   proxy_buffering off;
   proxy_http_version 1.1;
   proxy_pass_request_body off;
   proxy_pass_request_headers off;
   proxy_hide_header "x-amz-id-2";
   proxy_hide_header "x-amz-request-id";
   proxy_hide_header "x-amz-storage-class";
   proxy_hide_header "Set-Cookie";
   proxy_ignore_headers "Set-Cookie";
   proxy_set_header Host $backend;
   proxy_method GET;
   image_filter_interlace on;

   location ~ \/(?<producttitle>.+?)\/(?<image>.+?)-W(?<width>(\d+)).(?<ext>[a-z_]*)
     image_filter resize $width -;
     proxy_pass http://$backend/$producttitle/$image.$ext;
     error_page   415 = /empty;

   location = /empty {

and this is my config for caching:

server {
   listen 80;

   location ~ \/(?<producttitle>.+?)\/(?<image>.+?)-W(?<width>(\d+)).(?<ext>[a-z_]*)
     proxy_pass http://localhost:1111;
     proxy_cache mc_images_cache;
     proxy_cache_key "$host$document_uri$image$width";
     proxy_cache_lock on;
     proxy_cache_valid 200 30d;
     proxy_cache_valid any 15s;
     proxy_cache_use_stale error timeout invalid_header updating;
     proxy_http_version 1.1;
     expires 30d;


the issue I'm experiencing is getting 415 errors out of no where for some
of the width values I provide in the URL.
sometimes they work and sometimes I get 415.
nothing informative in debug log.

any idea what I'm doing wrong here?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx mailing list