module development: sharing data between different request phases
Severin Schoepke
schoepke at shortcutmedia.com
Wed Mar 25 10:20:37 UTC 2015
Hello there,
I'm in the process of writing a custom nginx module that should do some header
manipulation and some logging of strings created in that manipulation process.
The module/nginx then proxies the requests to another backend...
So far I have implemented a handler function that does the header manipulation
and added it to the ACCESS phase. Now I'm implementing a handler function that
should log some temporary data from the header manipulation to a file and added
it to the LOG phase.
Now I'm wondering how I can share/transfer some data/strings from the ACCESS
phase handler to the LOG phase handler?
- Is there some arbitrary user storage associated with a ngx_http_request_t that
I could use?
- Could I use variables for that? If so: how do I set a per-request variable in
one handler and read it in another?
- Or do I need to use a hack like storing the data in a X-Log-Data in either
headers_in or headers_out and reading it from this header in the log handler?
This feels very hacky and would expose the log data to the either the client or
the backend...
- Is there another hacky solution that I could use?
Thanks a lot!
cheers, Severin
More information about the nginx-devel
mailing list