Module: choose upstream server based on request body

st4ck0v3rfl0w st4ck0v3rfl0w at gmail.com
Tue May 21 12:52:25 UTC 2019


 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 :)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20190521/7807d772/attachment.html>


More information about the nginx-devel mailing list