Re: Handler invokation after upstream server being picked

can help a little with the code.
but instead its value becomes known when proxy module starts
working with a request.

Ok. Sorry - I saw in the proxy code that ngx_http_proxy_set_vars() is
called inside the proxy_pass directive handler. So I assumed they get
set on startup.

I should then be able to access the proxy_host variable during
the authentication phase (this is where my module sits).

Correct?

No, see above. The $proxy_host variable value is not known till
proxy started to work (and, if variables are used in proxy_pass,
evaluated its parameter).

But the value of the proxy_host will never change after startup, is that
right? I mean, it will always be the value of the proxy_host directve,
or? At least when I log the var, it always is.

Anyhow, do you have any suggestion how I best go about adding a request
header that is based on the proxy_host variable value.

(Background: I need to change the Authorization header, so that request
signature actually uses the right target host - see my original
question)

Jan

Hello!

On Tue, Nov 12, 2013 at 07:55:28PM +0100, Jan A. wrote:

can help a little with the code.
but instead its value becomes known when proxy module starts
working with a request.

Ok. Sorry - I saw in the proxy code that
ngx_http_proxy_set_vars() is called inside the proxy_pass
directive handler. So I assumed they get set on startup.

It’s called to cache appropriate values in location a
configuration (plcf->vars) if there are no variables in
proxy_pass. These values are later used to initialize run-time
data in ctx->vars once proxy starts handling a request (again, if
there are no variables in proxy_pass).

is that right? I mean, it will always be the value of the
proxy_host directve, or? At least when I log the var, it always
is.

In a simple configuration with proxy_pass without variables - it’s
always the same in a given location, yes. It can be anything in a
configuration like

proxy_pass $backend;

though.

Anyhow, do you have any suggestion how I best go about adding a
request header that is based on the proxy_host variable value.

(Background: I need to change the Authorization header, so that
request signature actually uses the right target host - see my
original question)

Write a configuration like this:

proxy_pass http://backend.example.com;
proxy_set_header Authorization $your_module_variable;

In your variable’s get handler obtain $proxy_host variable, do
needed calculations, and return a value you want to use in a
request to an upstream server.


Maxim D.
http://nginx.org/en/donation.html

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs