Welcome! Log In Create A New Profile

Advanced

Inserting a Request header before proxying

Posted by Anonymous User 
Anonymous User
Inserting a Request header before proxying
October 13, 2008 08:55AM
I'd like to insert a custom HTTP header (eg: X-foobar) into a request
before doing a proxy_pass.

Is there any way to do this without changing the proxy module itself? I
read that there can be only one handler per request. Though my module
retruns NGX_DECLINED after doing its job, it doesn't seem to get executed
first and proxy_pass seems to get invoked first.
Almir Karic
Re: Inserting a Request header before proxying
October 13, 2008 09:15AM
http://wiki.codemongers.com/NginxHttpProxyModule#proxy_set_header

On Sun, Oct 12, 2008 at 11:36:21PM -0700, work@anomalizer.net wrote:
> I'd like to insert a custom HTTP header (eg: X-foobar) into a request
> before doing a proxy_pass.
>
> Is there any way to do this without changing the proxy module itself? I
> read that there can be only one handler per request. Though my module
> retruns NGX_DECLINED after doing its job, it doesn't seem to get executed
> first and proxy_pass seems to get invoked first.
>
>
Arvind Jayaprakash
Re: Inserting a Request header before proxying
October 13, 2008 11:40AM
How do I set dynamic values?
X-Foobar: <some_code_that_looks_at_request_and_generates_a_value>


Almir Karic wrote:
> http://wiki.codemongers.com/NginxHttpProxyModule#proxy_set_header
>
> On Sun, Oct 12, 2008 at 11:36:21PM -0700, work@anomalizer.net wrote:
>> I'd like to insert a custom HTTP header (eg: X-foobar) into a request
>> before doing a proxy_pass.
>>
>> Is there any way to do this without changing the proxy module itself? I
>> read that there can be only one handler per request. Though my module
>> retruns NGX_DECLINED after doing its job, it doesn't seem to get executed
>> first and proxy_pass seems to get invoked first.
Igor Sysoev
Re: Inserting a Request header before proxying
October 13, 2008 11:45AM
On Mon, Oct 13, 2008 at 02:43:04PM +0530, Arvind Jayaprakash wrote:

> How do I set dynamic values?
> X-Foobar: <some_code_that_looks_at_request_and_generates_a_value>

You module should define a variable. See map and geo modules as examples.
Then you can use

proxy_set_header X-Foobar $your_variable;

> Almir Karic wrote:
> >http://wiki.codemongers.com/NginxHttpProxyModule#proxy_set_header
> >
> >On Sun, Oct 12, 2008 at 11:36:21PM -0700, work@anomalizer.net wrote:
> >>I'd like to insert a custom HTTP header (eg: X-foobar) into a request
> >>before doing a proxy_pass.
> >>
> >>Is there any way to do this without changing the proxy module itself? I
> >>read that there can be only one handler per request. Though my module
> >>retruns NGX_DECLINED after doing its job, it doesn't seem to get executed
> >>first and proxy_pass seems to get invoked first.


--
Igor Sysoev
http://sysoev.ru/en/
Sorry, only registered users may post in this forum.

Click here to login