Simple arithmetics in nginx config
agentzh
agentzh at gmail.com
Mon Nov 28 08:32:09 UTC 2011
On Mon, Nov 28, 2011 at 4:11 PM, mennanov <nginx-forum at nginx.us> wrote:
>
> location ~ /i/(.*)\.jpg {
> set $folder $1-($1%100);
> try_files /i/$folder/$1.jpg =400;
> }
>
> but of course it does not work due to syntax error.
>
The standard "set" directive does not support arithmetic operations at
all. But it's an ideal use case for our ngx_lua module:
location ~ /i/(.*)\.jpg {
set_by_lua $folder 'return ngx.var[1] - (ngx.var[1] % 100)';
try_files /i/$folder/$1.jpg =400;
}
See http://wiki.nginx.org/HttpLuaModule for details.
Regards,
-agentzh
More information about the nginx
mailing list