search headers_in?

agentzh agentzh at
Wed Sep 14 03:07:24 UTC 2011

On Wed, Sep 14, 2011 at 9:11 AM, Shaun savage <savages at> wrote:
> I am starting to write a new module that uses a header token.  I have
> searched google for the answer about "how to seach in headers for a
> name.  I want to search for "X-session-token".  I am surprised that
> there is not a library function that just does the search,

There's common code snippet that does the search :) See
nginx-1.0.6/src/http/modules/ngx_http_proxy_module.c, line 937, for

The ngx_headers_more modules also has this:

Another way is to read the nginx variable $http_HEADER on the C land.

> As I understand it now every module that wants to search for a header
> writes it own search function?

Sort of. It's simple enough.

> Is there a "library search function"?

Not any that I'm aware of :)

> once I have the session token I use memcached in the PREACCESS phase to
> load the session info, then in the ACCESS phase check the access permission.

Just be sure you use a non-blocking approach to access memcached. You
can take the ngx_srcache module for an example:

even though it can also work with other backends like ngx_redis2 and
ngx_redis :)


More information about the nginx-devel mailing list