# Handler invokation after upstream server being picked

**URL:** <https://www.ruby-forum.com/t/handler-invokation-after-upstream-server-being-picked/237106>\
**Category:** NGINX\
**Created:** [October 25, 2013, 12:31pm UTC](https://www.ruby-forum.com/t/handler-invokation-after-upstream-server-being-picked/237106 "2013-10-25T12:31:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jandot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jandot](https://www.ruby-forum.com/u/jandot)\
**Post date:** [October 25, 2013, 12:31pm UTC](https://www.ruby-forum.com/t/handler-invokation-after-upstream-server-being-picked/237106/1 "2013-10-25T12:31:12Z")

</div>

Hi,

I am writing a module that needs to add/change the HTTP Authorization  
server for an upstream request.

Since I am using a signature based authentication scheme where the  
signature base string includes the request host and port the header can  
only be added _after_ the upstream module has determined which server to  
send the request to (e.g. after applying round-robin).

Is it possible to hook my module into that ‘phase’ and if so - what is  
the preferred way to do that?

I saw that I at least can access the target host and port set by the  
proxy module by reading the proxy module variables. However, that (of  
course) does only give the server group name to be used by the upstream  
module in the next step.

Jan

---

<div class="post-metadata">

**Author:** ![jandot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jandot](https://www.ruby-forum.com/u/jandot)\
**Post date:** [October 25, 2013, 4:07pm UTC](https://www.ruby-forum.com/t/handler-invokation-after-upstream-server-being-picked/237106/2 "2013-10-25T16:07:28Z")

</div>

Hello!

On Fri, Oct 25, 2013 at 12:30:34PM +0200, Jan A. wrote:

> Is it possible to hook my module into that ‘phase’ and if so -  
> what is the preferred way to do that?
> 
> I saw that I at least can access the target host and port set by  
> the proxy module by reading the proxy module variables. However,  
> that (of course) does only give the server group name to be used  
> by the upstream module in the next step.

A request to an upstream is created once, before a particular  
server is known, and the same request is used for requests to all  
upstream servers. That is, what you are trying to do isn’t  
something currently possible.

–  
Maxim D.  
[http://nginx.org/en/donation.html](http://nginx.org/en/donation.html)
