Maxim, a while ago you replied to my question below.
Since yesterday I am trying to get hold of the proxy_host variable set by the proxy module but without success, maybe you can help a little with the code. >From the source I understood that the proxy module sets the proxy_host var >during NGINX startup. I guess, that happens on a per-location basis, depending >on encountering a proxy_pass directive. Correct? I should then be able to access the proxy_host variable during the authentication phase (this is where my module sits). Correct? To get hold of it, I try to find the index of the proxy_host var in my location config merge handler: var.data = (unsigned char*)"proxy_host"; var.len = 10; child->proxy_host_var_index = ngx_http_get_variable_index(cf, &var); if (child->proxy_host_var_index == NGX_ERROR) { /* NOT FOUND, TRY TO INHERIT */ child->proxy_host_var_index = parent->proxy_host_var_index; return NGX_CONF_OK; } /* FOUND - This loca config has its own proxy_pass configuration */ In my handler, I then do this: ngx_http_variable_value_t *value; ... value = ngx_http_get_indexed_variable(r, conf->proxy_host_var_index); Does that make sense? I does not work for me, unfortunately. (The log module does see the proxy_host variable and logs the expected value for it. Jan > Hello! > > On Fri, Oct 25, 2013 at 12:30:34PM +0200, Jan Algermissen wrote: > >> 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. > > 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 Dounin _______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx