proxy_next_upstream and POSTs

Jonathan Leibiusky ionathan at gmail.com
Tue May 10 18:09:45 MSD 2011


Thanks! That guide was really useful.
I almost have it done. What is missing there is how to test and maybe
something even more generic.
Once I finish my module I will try to write an even more basic guide
to help people :)

Jonathan

On 5/10/11, Antoine Bonavita <antoine.bonavita at gmail.com> wrote:
> Hello,
>
> You might want to have a look at Evan's Miller section on proxying
> handlers: http://www.evanmiller.org/nginx-modules-guide.html#proxying
> This page is pretty much considered *the* reference for module development.
>
> Enjoy,
>
> Antoine.
> --
> Low fare on trips to nginx land: visit http://www.nginx-discovery.com
>
> On Tue, May 10, 2011 at 12:37 AM, Jonathan Leibiusky <ionathan at gmail.com>
> wrote:
>> I read some modules out there and could manage to write a custom module
>> that
>> will do the job. I have some doubts though.
>> How can I call the original upstream module from my own upstream module? I
>> don't want to replace it.
>>
>> I think the magic might go here:
>> ngx_http_upstream_init_<module name>_peer method. Is that right? Is there
>> any example that I can use?
>>
>> Thanks!
>>
>> Jonathan
>>
>> On Mon, May 9, 2011 at 1:42 PM, Jonathan Leibiusky <ionathan at gmail.com>
>> wrote:
>>>
>>> Hi!
>>> Nginx is great and the way it handles upstream and failed server as well!
>>> I would just like to avoid retrying request when they are POSTs, as POSTs
>>> are no idempotent and my backend can't handle duplicated POSTs right now.
>>> So I started to mess around with the code. What I have in mind is to
>>> create a module that will change the behavior of proxy_next_upstream by
>>> just
>>> checking that http method != POST.
>>> I believe it supposed to be really simple.
>>> So a couple of questions for those who are into nginx source code:
>>> 1. Is there any good article, blog post, etc, that explain how to create
>>> and test a module?
>>> 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;
>>> }
>>>
>>> If this is OK, how could I do this from a module? So when someone
>>> compiles
>>> nginx with this module, he'll have this behavior instead of the standard
>>> one?
>>>
>>> Sorry if my questions are dumb.
>>>
>>> Jonathan
>>
>>
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://nginx.org/mailman/listinfo/nginx
>>
>>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>



More information about the nginx mailing list