<div dir="ltr">It sounds like you want to control what upstream servers are available based on a set of criteria.<div><br></div><div>This setup might do what you want, just not implemented in the exact way you desire: <a href="https://medium.com/@sigil66/dynamic-nginx-upstreams-from-consul-via-lua-nginx-module-2bebc935989b">https://medium.com/@sigil66/dynamic-nginx-upstreams-from-consul-via-lua-nginx-module-2bebc935989b</a></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 17, 2017 at 7:01 AM, rnmx18 <span dir="ltr"><<a href="mailto:nginx-forum@forum.nginx.org" target="_blank">nginx-forum@forum.nginx.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have a requirement to de-select or exclude one or more servers from an<br>
upstream group, if that server is either just newborn or exhausted<br>
(overloaded or showing reduced performance).<br>
<br>
So, consider there are servers A, B and C in the upstream group. An external<br>
program periodically checks A, B and C and keeps track of different<br>
parameters (uptime, average response time etc), and assigns a "good" or<br>
"bad" status flag to each of them.<br>
<br>
I would like to implement a mechanism in NGINX, in which it can periodically<br>
(say every 5 minutes) communicate with this external program and collect the<br>
status flag for A,B and C. This would be an HTTP communication with a<br>
response in a parse-able text format. Assume if B is reported as "bad", I<br>
would like to exclude B temporarily, till I get a "good" value back for it.<br>
<br>
I am aware of the native upstream healthcheck mechanism in NGINX.<br>
<br>
However, the requirement here is to bring some additional parameters into<br>
consideration for the selection of upstream.<br>
<br>
I would like to know whether this is feasible to realize in NGINX. Could<br>
someone please explain some design insights for this problem?<br>
<br>
Going a bit deeper, I could identify the following potential requirements or<br>
questions?<br>
<br>
a) Should I depend on both (a) the passive upstream check native to NGINX<br>
and (b) the status value to be obtained from the external process? I think<br>
since the native health check is passive in nature (like when NGINX tries to<br>
connect to an upstream when it wants to proxy the request), it is beyond my<br>
programmable-control. So, I needn't worry about that. What I should be<br>
worried is about enabling NGINX to dynamically exclude a particular server,<br>
based on a "bad" feedback from the external process.<br>
<br>
b) How to communicate periodically with the external process over HTTP? How<br>
can I get an HTTP client functionality in NGINX to send an external request<br>
and process the response? Can I build this functionality as an NGINX<br>
module?<br>
<br>
c) Last but not the least, I would need some mechanism by which I should be<br>
able to map the server(s) reported as "bad" to the configured upstream<br>
servers, and then temporarily exclude them (mark down), and later include<br>
them when the status changes to "good".<br>
<br>
Thanks<br>
Rajesh<br>
<br>
Posted at Nginx Forum: <a href="https://forum.nginx.org/read.php?2,276912,276912#msg-276912" rel="noreferrer" target="_blank">https://forum.nginx.org/read.<wbr>php?2,276912,276912#msg-276912</a><br>
<br>
______________________________<wbr>_________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/<wbr>mailman/listinfo/nginx</a><br>
</blockquote></div><br></div>