Welcome! Log In Create A New Profile

Advanced

Re: How to obtain location field in my module

Maxim Dounin
December 13, 2013 01:30PM
Hello!

On Fri, Dec 13, 2013 at 11:06:47AM +0400, Deymon wrote:

>
> Hi friends!
> I have a question: How can I obtain the location path in http-handler which
> handles requests intended to this location?
> Here is what I mean:
>
> http {
>   ...
>
>   server {
>     ...
>
>     location <location_path> { # I need
> <location_path> value
>         ...
>     }
>
>     ...
>   }
>
>   ...
> }
>
>  Thanks for attention!

The is "name" in ngx_http_core_module location config, but note
that it's not always a path - there are named and/or regexp
locations.

E.g., the proxy module does this during configuration merge to
later use the location path in internal operations:

clcf = ngx_http_conf_get_module_loc_conf(cf, ngx_http_core_module);

...

plcf->location = clcf->name;

if (clcf->named
#if (NGX_PCRE)
|| clcf->regex
#endif
|| clcf->noname)
{
if (plcf->vars.uri.len) {
ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
"\"proxy_pass\" cannot have URI part in "
"location given by regular expression, "
"or inside named location, "
"or inside \"if\" statement, "
"or inside \"limit_except\" block");
return NGX_CONF_ERROR;
}

plcf->location.len = 0;
}

See http/modules/ngx_http_proxy_module.c for all the code.

--
Maxim Dounin
http://nginx.org/

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

Modules developing

Deymon 807 October 24, 2013 11:02AM

Re: Modules developing

Maxim Dounin 371 October 24, 2013 12:34PM

How to obtain location field in my module

Deymon 378 December 13, 2013 02:08AM

Re: How to obtain location field in my module

Maxim Dounin 405 December 13, 2013 01:30PM



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

Online Users

Guests: 246
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready