Welcome! Log In Create A New Profile

Advanced

Module: choose upstream server based on request body

st4ck0v3rfl0w
May 21, 2019 08:54AM
Hi,

I want to create a module, that fastcgi_passes a request to different
servers based on the content of the post request. Initially I had two ideas:

1. Create a load balancer module: I was not successful with this, because I
did not know how to access the request.

2. Create a variable that classifies the request based on the content, then
map it on server addresses and call fastcgi_pass on the map variable. This
seems easy and elegant, but the r->request_body variable is NULL for me.

What I did:
- create module without directive
- call ngx_http_add_variable in the preconfig function
- set a getter for the variable
- try to read r->request_body in the getter

I just cannot find a lot of information about this online. I probably
should call ngx_http_read_client_request_body at some point, but I am
struggling how to use it correctly.

How can I make the request_body available when reading the variable? Is
there a different and easier / more elegant way to solve this?

Thanks for your time :)
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

Module: choose upstream server based on request body

st4ck0v3rfl0w 320 May 21, 2019 08:54AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 150
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready