<div dir="ltr"><div>Hello,</div><div><br></div><div>Thanks for the explanation. I will look into the options what we have at this point.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 15, 2020 at 3:27 AM Francis Daly <<a href="mailto:francis@daoine.org">francis@daoine.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, Dec 14, 2020 at 06:57:50PM +0530, Praveen Kumar K S wrote:<br>
<br>
Hi there,<br>
<br>
> 1. nginx fails to start when an upstream server is down or not being<br>
> resolved.<br>
<br>
"nginx fails to start when an upstream server is down" is not the<br>
expected behaviour.<br>
<br>
"nginx fails to start when an upstream server name is not being resolved"<br>
is the expected behaviour.<br>
<br>
If you have a reproducible case of the first without the second, that<br>
will probably be a useful bug report.<br>
<br>
> 2. I can't use the ipaddress because I'm running all services in docker<br>
> swarm. So I can only resolve using the service names.<br>
<br>
That's a valid setup for your use case.<br>
<br>
Stock-nginx does not work in those circumstances, if the upstream service<br>
names do not resolve when nginx starts.<br>
<br>
(Also: I think that stock-nginx will not try to re-resolve the names<br>
while it is running; so giving it "dummy" information at startup and<br>
changing it later, will not work.)<br>
<br>
> 3. Now I get your point. When nginx starts, it should resolve all upstream<br>
> servers. Else, it will fail to start.<br>
<br>
Correct.<br>
<br>
> Now, let me explain my issue. Please let me know if this is possible.<br>
> 1. Today I have 3 servers defined in upstream. Lets say app1,app2,app3<br>
> 2. Tomorrow I might scale the app by 2 more. Lets say app4,app5<br>
> 3. Now I want to define that [app4,app5] in my nginx configuration<br>
> 4. But I thought of defining app1,2,3,4,5 upfront in nginx conf and scale<br>
> my app whenever required. In this case, when nginx is unable to resolve<br>
> app4,5, it should ignore and when I scale my app, it should load balance<br>
> the requests to all 5.<br>
<br>
Step 4 is not a thing that stock-nginx can do today.<br>
<br>
You could potentially define your "upstream" to only include the servers<br>
that resolve today; and then tomorrow change it to only include the<br>
servers that resolve tomorrow, and invite nginx to re-read its config<br>
file ("reload" rather than "restart").<br>
<br>
Or you could potentially define your "upstream" with all 5 names if you<br>
know the IP addresses that they will have when they are running, and<br>
let nginx load-balance across whichever services are "up" at each time.<br>
<br>
<br>
Maybe you can find or write an external module that can get nginx to do<br>
what you want?<br>
<br>
The documentation for "upstream" is at <a href="http://nginx.org/r/upstream" rel="noreferrer" target="_blank">http://nginx.org/r/upstream</a><br>
<br>
On that page, there are also mentions of some dynamic features that are<br>
not available in stock nginx, but which are available in a commercial<br>
subscription. Depending on your requirements, that may or may not be<br>
a useful path to investigate. The fact that "dynamic configuration"<br>
code exists proves that it can be written, which might be inspiration<br>
to re-implement it, or to take advantage of what others have already done.<br>
<br>
Good luck with it,<br>
<br>
f<br>
-- <br>
Francis Daly <a href="mailto:francis@daoine.org" target="_blank">francis@daoine.org</a><br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><font style="font-family:"courier new",monospace" size="1"><b style="color:rgb(102,102,102)">Regards,<br><br></b></font><div style="color:rgb(102,102,102)"><font size="1"><b><font face="'comic sans ms', sans-serif"><font style="font-family:"courier new",monospace" size="1">K S Praveen Kumar<br></font><br></font></b></font></div></div></div>