0
upstream test {
    server ip1:port1;
    server ip1:port2;
    server ip1:port3;
    server ip1:port4;
}
location / {
    set $dst  test;
    proxy_pass http://$dst;
}

Approach -
Initially in the database, I stored the request count of each upstream IP in the upstream block with zero. When a request is made to Nginx, I get the upstream IP used by proxy_pass, Then perform an ngx.location.capture subrequest to the database to increment the count of an upstream IP.

But How can I perform ngx.location.capture after proxy_pass?

Is there any other approach to achieve this?

Can anyone help me with this?

0 Answers0