Simple arithmetics in nginx config

mennanov nginx-forum at nginx.us
Tue Nov 29 08:35:52 UTC 2011


agentzh Wrote:
-------------------------------------------------------
> 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
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx

Thank you so much, i've just recompiled nginx with this module and it
just works!

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,219172,219260#msg-219260



More information about the nginx mailing list