Tracking sent responses

Sergey Brester serg.brester at sebres.de
Wed Nov 11 19:09:39 UTC 2015


 

11.11.2015 19:17, Julien FROMENT wrote: 

> Thanks for the reply,

Welcome :) 

> Using post_action could work, if we can sent to the @after_request_location enough reliable information. 
> 
> Can we use the all the variable documented in the ngx_http_core_module (http://nginx.org/en/docs /http/ngx_http_core_module.html#variables [1]) ? Are there any other variables that we could use?

Yes, and your own specified also (or some from custom modules). 

Here is a more large list of all variables -
http://nginx.org/en/docs/varindex.html 

And if you want to use some values returned from upstream you should get
a variables beginning with "upstream_...".
For example, if you need a http-header "X_MY_VAR", you should get
$upstream_http_x_my_var.
If you need a cookie value "example", you can get
$upstream_cookie_example etc. For http status of response use
$upstream_status. Here is the list of it all -
http://nginx.org/en/docs/http/ngx_http_upstream_module.html#var_upstream_addr

> Although, I am a bit concerned by your comment "possibly not recommended to use", could we clarify what you mean or what lead you to think it is not recommended?

Well, you can read my small discussion with unambiguous answer about
this from a nginx developer -
https://www.mail-archive.com/nginx-devel@nginx.org/msg03680.html 

I will keep this feature in my own bundles (and in my own forks) - no
matter what some nginx developers say about this. 
But ... it is my decision about. 

In any case, I believe it is not very complex to create a similar
functionality as (replacement) module, if "post_action" will be removed
later from nginx standard bundle. 

> Rergard, 
> 
> Julien

Regards,
Serg G. Brester (sebres)

> FROM: Sergey Brester [mailto:serg.brester at sebres.de] 
> SENT: Tuesday, November 10, 2015 2:30 PM
> TO: nginx-devel at nginx.org
> CC: Julien FROMENT
> SUBJECT: Re: Tracking sent responses 
> 
> Hi, 
> 
> I'm sure you can do that using on-board "equipment" of nginx, without deep integrating to the nginx (without write of own module). 
> 
> You can use for this a "post_action", something like:
> 
> post_action @after_request_location; 
> 
> But (There is always a "but":), according to my last known stand: 
> 
> - the feature "post_action" is asynchronously;
> - the feature is not documentated (and possibly not recommended to use);- if location "executed" in post_action uses upstreams (fcgi, proxy_pass, etc.), it will always breaks a keepalive connection to the upstream channel (possibly fixed, but I've missed). 
> 
> Regards,
> sebres. 
> 
> Am 10.11.2015 19:51, schrieb Julien FROMENT: 
> 
>> Hello, 
>> 
>> We would like to use Nginx to keep track of exactly what part of an upstream's server response was sent over a socket. Nginx could call an API asynchronously with the number of bytes sent over the socket for a given request. 
>> 
>> &nbs p; 
>> 
>> Here is the pseudo code: 
>> 
>> -- Client send a request 
>> 
>> -- Nginx processes the request and send it to the upstream 
>> 
>> ... 
>> 
>> -- The upstream returns the response 
>> 
>> -- Nginx sends the response to the client 
>> 
>> -- Nginx calls Async API with the number of bytes sent 
>> 
>> I read a little bit of "Emiller's Guide To Nginx Module Development", and I think we could write a Handler that provide some tracking information. But I am unsure if it is possible to hook it at a low enough level for our needs. 
>> 
>> Are there any expert on this mailing list that could provide us consulting services and guide us through the development of such functionality? 
>> 
>> Thanks in advance! 
>> 
>> Julien 
>> 
>> #
>> 
>> " Ce courriel et les documents qui lui sont joints peuvent contenir des
>> 
>> informations confidentielles ou ayant un caractè privÃ(c)S'ils ne vous sont
>> 
>> pas destinÃ(c) nous vous signalons qu'il est strictement interdit de les
>> 
>> divulguer, de les reproduire ou d'en utiliser de quelque maniè que ce
>> 
>> soit le contenu. Si ce message vous a Ã(c) transmis par erreur, merci d'en
>> 
>> informer l'expÃ(c)teur et de supprimer immÃ(c)atement de votre systè
>> 
>> informatique ce courriel ainsi que tous les documents qui y sont attachÃ(c)"
>> 
>> ******
>> 
>> " This e-mail and any attached documents may contain confidential or
>> 
>> proprietary information. If you are not the intended recipient, you are
>> 
>> notified that any dissemination, copying of this e-mail and any attachments
>> 
>> thereto or use of their contents by any means whatsoever is strictly
>> 
>> prohibited. If you have received this e-mail in error, please advise the
>> 
>> sender immediately and delete this e-mail and all attached documents
>> 
>> from your computer system."
>> 
>> #
>> 
>> _______________________________________________
>> 
>> nginx-devel mailing list
>> 
>> nginx-devel at nginx.org
>> 
>> http://mailman.nginx.org/mailman/listinfo/nginx-devel [2]
> 
> #
> " Ce courriel et les documents qui lui sont joints peuvent contenir des
> informations confidentielles ou ayant un caractè privéS'ils ne vous sont
> pas destiné nous vous signalons qu'il est strictement interdit de les
> divulguer, de les reproduire ou d'en utiliser de quelque maniè que ce
> soit le contenu. Si ce message vous a é transmis par erreur, merci d'en
> informer l'expéteur et de supprimer imméatement de votre systè
> informatique ce courriel ainsi que tous les documents qui y sont attaché"
> 
> ******
> 
> " This e-mail and any attached documents may contain confidential or
> proprietary information. If you are not the intended recipient, you are
> notified that any dissemination, copying of this e-mail and any attachments
> thereto or use of their contents by any means whatsoever is strictly
> prohibited. If you have received this e-mail in error, please advise the
> sender immediately and delete this e-mail and all attached documents
> from your computer system."
> #
 

Links:
------
[1] http://nginx.org/en/docs/http/ngx_http_core_module.html#variables
[2] http://mailman.nginx.
org/mailman/listinfo/nginx-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20151111/101af5e1/attachment.html>


More information about the nginx-devel mailing list