Handlers

Wandenberg Peixoto wandenberg at gmail.com
Wed Aug 14 12:54:22 UTC 2013


Hi John,

no, you don't have to change any code on nginx core, if this was your doubt.

You have to create your own module, (take a look on this page as a guide,
http://www.evanmiller.org/nginx-modules-guide.html).
On the "handler installation" part, instead of doing what the guide said,
replace by the code I sent.
On this code you are registering more one handler at access phase (pushing
more one position on the array "h = ngx_array_push")
and telling that this handler will be the function you have developed.

With that, nginx will execute any access handler configured by other
modules including yours, and than execute the final handler.

Regards,
Wandenberg



On Tue, Aug 13, 2013 at 9:04 PM, Myla John-B22173 <B22173 at freescale.com>wrote:

>  Hi Wandenberg Peixoto,****
>
> ** **
>
> I appreciate your response.****
>
> ** **
>
> I have a simple follow-up question. I have looked at the function
> ngx_http_access_handler and it is checking for access privileges.****
>
> ** **
>
> Do you suggest to over write this functionality or add my code here
> (before exiting the function calling my routine)?****
>
> ** **
>
> Regards,****
>
> John****
>
> ** **
>
> *From:* nginx-devel-bounces at nginx.org [mailto:
> nginx-devel-bounces at nginx.org] *On Behalf Of *Wandenberg Peixoto
> *Sent:* Tuesday, August 13, 2013 7:51 AM
> *To:* nginx-devel at nginx.org
> *Subject:* Re: Handlers****
>
> ** **
>
> You can use an accept handler to do that.
> something like that
>
> ngx_http_handler_pt        *h;
> ngx_http_core_main_conf_t  *cmcf;
>
> cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
>
> h = ngx_array_push(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers);
> if (h == NULL) {
>     return NGX_ERROR;
> }
>
> *h = your_handler_function;****
>
> and in your_handler_function you record the request and return a NGX_OK,
> which allow the request to continue to the next handler.****
>
> ** **
>
> ** **
>
> On Mon, Aug 12, 2013 at 9:11 PM, Myla John-B22173 <B22173 at freescale.com>
> wrote:****
>
> Hi,****
>
>  ****
>
> I am VERY new to NGINX and trying to understand how it works. I understand
> there are 3 main components, handlers, filters and load balancers and there
> can be multiple “Filters”. ****
>
> My question is, can we have multiple “Handlers”?  I want to develop a
> module, which need to capture all the requests, need to record these
> requests and continue the normal processing.****
>
>  ****
>
> Regards,****
>
> John    ****
>
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel****
>
> ** **
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20130814/162107bb/attachment.html>


More information about the nginx-devel mailing list