Hello!
On Wed, Dec 11, 2013 at 11:54 AM, Ankit Jain wrote:
Thought it
> was not available as it wasn't mentioned in the list given at:
> https://github.com/chaoslawful/lua-nginx-module#ndkset_vardirective.
>
Well, that list is never meant to be exhaustive because this is an open API.
Anyone can write his own Nginx C module based on NDK and get his new
directives (based on ndk_set_var_value) reusable on the Lua land via
the ndk.set_var API.
> Though my question now is that is it safe to use NDK in production
> enviroment even when I would be using it only for this one directive?
NDK and the ndk.set_var API have been used in production environment
for a few years already.
> does
> it add any overhead or can cause any performance issues?
>
The current implementation of the ndk.set_var API is rather efficient
and the nginx directive lookup is only done once and the result is
cached. You can always benchmark the performance yourself anyway :)
The set_secure_random_alphanum directive itself might be a bit
expensive in that it requires opening, reading, and closing the
/dev/urandom file. All are expensive system calls. So you'd better do
that all by yourself in Lua and cache the file handle for the
/dev/urandom device. It's not hard at all.
Regards,
-agentzh