Welcome! Log In Create A New Profile

Advanced

Re: Installing handlers in NGX_HTTP_LOG_PHASE

Piotr Sikora
December 23, 2009 05:44AM
> However, what I want to achieve is to install the handler
> conditionally. So when you in your nginx.conf say:
>
> location /
> perl_log_handler MyModule::log_handler
>
> I tried the following approach and failed:
>
> static ngx_command_t ngx_http_perl_commands[] = {
> ....
> { ngx_string("perl_log_handler"),
> NGX_HTTP_LOC_CONF|NGX_HTTP_LMT_CONF|NGX_CONF_TAKE1,
> ngx_http_perl_handler_init,
> NGX_HTTP_LOC_CONF_OFFSET,
> 0,
> NULL },
> ....
> };

ngx_http_perl_handler_init should stay in postconfiguration init phase. What
you should do to use this feature conditionally is to use yourcf->enable
flag (for working example check ngx_http_autoindex_module.c).

This is because you don't set new handler but you are adding new one to the
processing chain and your handler will be called for every single request
(so you must return NGX_DECLINE as soon as possible when it isn't enabled).

Best regards,
Piotr Sikora < piotr.sikora@frickle.com >


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Installing handlers in NGX_HTTP_LOG_PHASE

Srebrenko Šehić 4489 December 23, 2009 04:50AM

Re: Installing handlers in NGX_HTTP_LOG_PHASE

Maxim Dounin 1436 December 23, 2009 05:08AM

Re: Installing handlers in NGX_HTTP_LOG_PHASE

Srebrenko Šehić 1369 December 23, 2009 07:54AM

Re: Installing handlers in NGX_HTTP_LOG_PHASE

Maxim Dounin 1992 December 23, 2009 08:46AM

Re: Installing handlers in NGX_HTTP_LOG_PHASE

Piotr Sikora 1425 December 23, 2009 05:44AM

Re: Installing handlers in NGX_HTTP_LOG_PHASE

Srebrenko Šehić 1343 December 23, 2009 07:56AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 100
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready