M
M
MegaLoadOn2019-04-10 11:30:14
linux
MegaLoadOn, 2019-04-10 11:30:14

How to rewrite such request to nginx?

I use the ngx_small_light module for image resizing ( https://github.com/cubicdaiya/ngx_small_light)
The module works in 2 versions. Or:

small_light on;
location ~ small_light[^/]*/(.+)$ {
    set $file $1;
    rewrite ^ /$file;
}

Original here - $host:$port/img/image.jpg
Resize here - $host:$port/small_light(dw=300,dh=300)/img/image.jpg
Either:
small_light on;
small_light_pattern_define msize dw=300,dh=300,da=l,q=95,e=imagemagick,jpeghint=y;
location ~ small_light[^/]*/(.+)$ {
        set $file $1;
        rewrite ^ /$file;
    }

Original here - $host:$port/img/image.jpg
Resize here - $host:$port/small_light(p=msize)/img/image.jpg
Everything works ok.
How to rewrite, so that the resize could be received by passing to:
$host:$port/300x300/img/image.jpg
Width 300 and height 300 are taken as an example. They can be anything.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2019-04-10
@MegaLoadOn

Switch to using GET parameters.

small_light_getparam_mode on;
rewrite ^/(\d+)x(\d+)(/img/.+) $3?dw=$1&dh=$2;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question