Nginx的image_filter

我在S3上存储静态,并使用nginx作为前端。 从S3中获取我使用这种结构:

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; } 

这工作! 但我想生成大拇指,并使用此位置:

 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; } 

但是这不起作用,nginx返回415 Unsupported Media Type 。 什么错?

你可能会喜欢在url的每个部分使用location指令:t / m / l。

 location ( ~ ^/t/ ) { set $w 182; set $h 114; root /; image_filter crop $w $h; }