atom feed10 messages in ru.sysoev.nginxRe: proxy_next_upstream and POSTs
FromSent OnAttachments
Jonathan LeibiuskyMay 9, 2011 9:42 am 
Jonathan LeibiuskyMay 9, 2011 3:37 pm 
Antoine BonavitaMay 10, 2011 12:21 am 
Jonathan LeibiuskyMay 10, 2011 7:09 am 
Piotr SikoraMay 10, 2011 7:31 am 
Jonathan LeibiuskyMay 10, 2011 7:47 am 
Jonathan LeibiuskyMay 10, 2011 12:30 pm 
Antoine BonavitaMay 11, 2011 1:02 am 
agentzhMay 12, 2011 3:30 am 
agentzhMay 12, 2011 3:34 am 
Subject:Re: proxy_next_upstream and POSTs
From:Jonathan Leibiusky (iona@gmail.com)
Date:May 10, 2011 7:47:53 am
List:ru.sysoev.nginx

Right, that is why after digging for a while I realized I wan't doing it the right way. Now I wrote a module that will hook into the upstream logic and will set all the callbacks to the round-robin callbacks. Only the the peer.free callback will call the original round-robin callback and after that will do something like:

if (r->method == NGX_HTTP_POST) { pc->retries = 0; }

by setting retires = 0 I think nginx won't retry and will fail and I will be using round-robin logic for all the rest.

My only problem is that in the peer.free callback I don't have access to the request struct, so I don't know is the request's method. So now I am not sure if the approach is the right one.

Any thoughts on this?

On Tue, May 10, 2011 at 11:32 AM, Piotr Sikora <piot@frickle.com>wrote:

Hi,

2. Any good advice on how I should do it? I was thinking on adding the

validation somewhere in ngx_http_upstream_test_next (ngx_http_upstream.c), something like: if (r->method == NGX_HTTP_POST) { return NGX_DECLINED; }

Keep in mind that you should decline sending request to another backend, only if you already sent it upstream. There is a bunch of errors (bad gateway, connection timeout, etc) which could lead to the code path in question, for which you should still send request to another backend.