3

我将静态存储在 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 return 415 Unsupported Media Type。怎么了?

4

1 回答 1

0

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

location ( ~ ^/t/ ) {
    set $w 182;
    set $h 114;
    root /;
    image_filter crop $w $h;
}
于 2013-05-24T11:39:54.947 回答