NGINX Module - create variables‏

Hi,

I would like to create a small module which execute some routines,
returns an NGX_OK, somewhat similar in concept to
http://blog.zhuzhaoyuan.com/2009/08/creating-a-hello-world-nginx-module/

However
I would like once the module executes to create variables such as
$my_var which would be accessible via config files to other blocks or to
the same location block.

I am aware of the “register_variable”
option, with “ngx_http_variable_t *var, *v;” - but the examples I have
seen so far, execute the module only once this variable is loaded in the
config file.

What I would like is being able to define a couple
of config variables once my module is loaded. Is this possible at all?
If so, could you point me to a sample/module which does this so I can
learn from it?

Many thanks,

Alex

Hello!

On Fri, Dec 06, 2013 at 12:25:48AM +0100, Alex Koch wrote:

[…]

What I would like is being able to define a couple
of config variables once my module is loaded. Is this possible at all?
If so, could you point me to a sample/module which does this so I can
learn from it?

You may try looking into the stub status module,
src/http/modules/ngx_http_stub_status_module.c. It defines
several variables ($connections_active, $connections_reading,
$connections_writing, $connections_waiting) and it’s easy enough
to follow.

http://hg.nginx.org/nginx/file/tip/src/http/modules/ngx_http_stub_status_module.c


Maxim D.
http://nginx.org/en/donation.html

Great. Thanks! This was in fact helpful.

Alex

Hello,

I would appreciate any hints.

Many thanks,

Alex

From: [email protected]
To: [email protected]
Subject: NGINX Module - create variables
Date: Tue, 3 Dec 2013 18:55:52 +0100

Hi,

I would like to create a small module which execute some routines,
returns an NGX_OK, somewhat similar in concept to
http://blog.zhuzhaoyuan.com/2009/08/creating-a-hello-world-nginx-module/

However
I would like once the module executes to create variables such as
$my_var which would be accessible via config files to other blocks or to
the same location block.

I am aware of the “register_variable”
option, with “ngx_http_variable_t *var, *v;” - but the examples I have
seen so far, execute the module only once this variable is loaded in the
config file.

What I would like is being able to define a couple
of config variables once my module is loaded. Is this possible at all?
If so, could you point me to a sample/module which does this so I can
learn from it?

Many thanks,

Alex

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs