Hi guys
a novice here so go easy on me with this question:
having multiple 'listen' with IPs or, just one 'listen' with a hostname
which resolves to more than one IP - is it possible to tell Nginx not
fail when one of IPs is absent, does not exist?
many thanks, L.
On Sat, Feb 12, 2022 at 10:11:25AM +0000, lejeczek via nginx wrote:
Hi there,
> having multiple 'listen' with IPs or, just one 'listen' with a hostname
> which resolves to more than one IP - is it possible to tell Nginx not fail
> when one of IPs is absent, does not exist?
I think that stock nginx does not support that.
There are possibly ways to avoid the failure; but they all fundamentally
are different ways to do "only bind to locally-existing addresses".
Cheers,
f
--
Francis Daly francis at daoine.org
Hello!
On Sat, Feb 12, 2022 at 10:11:25AM +0000, lejeczek via nginx wrote:
> having multiple 'listen' with IPs or, just one 'listen' with a hostname
> which resolves to more than one IP - is it possible to tell Nginx not
> fail when one of IPs is absent, does not exist?
nginx won't fail if it also listens on * with the same port (as it
won't actually try to listen on the particular IP addresses in
this case, see the description of the "bind" parameter at
http://nginx.org/r/listen).
--
Maxim Dounin
http://mdounin.ru/
On 12/02/2022 13:26, Francis Daly wrote:
> On Sat, Feb 12, 2022 at 10:11:25AM +0000, lejeczek via nginx wrote:
>
> Hi there,
>
>> having multiple 'listen' with IPs or, just one 'listen' with a hostname
>> which resolves to more than one IP - is it possible to tell Nginx not fail
>> when one of IPs is absent, does not exist?
> I think that stock nginx does not support that.
>
> There are possibly ways to avoid the failure; but they all fundamentally
> are different ways to do "only bind to locally-existing addresses".
>
> Cheers,
>
> f
I can confess I return to Nginx after long many years of a divorce and
this curious fact - if Nginx cannot do that - will be a surprise to me.
I thought such a "feature" would be in Nginx by now, if not devised by
developers than included by popular demand - looking at the
options/params to 'listen', something like 'remain' or 'insist' which
would instruct Nginx to start & continue to work and hook onto the IP
when/after it appeared(but also continue to work after IP disappeared)
thanks, L.
On Sun, Feb 13, 2022 at 07:56:16AM +0000, lejeczek via nginx wrote:
> On 12/02/2022 13:26, Francis Daly wrote:
> > On Sat, Feb 12, 2022 at 10:11:25AM +0000, lejeczek via nginx wrote:
Hi there,
> > > having multiple 'listen' with IPs or, just one 'listen' with a hostname
> > > which resolves to more than one IP - is it possible to tell Nginx not fail
> > > when one of IPs is absent, does not exist?
> > I think that stock nginx does not support that.
> >
> > There are possibly ways to avoid the failure; but they all fundamentally
> > are different ways to do "only bind to locally-existing addresses".
> I can confess I return to Nginx after long many years of a divorce and this
> curious fact - if Nginx cannot do that - will be a surprise to me.
Use cases tend to be addressed when a developer has the incentive to
write the code.
If the feature that you are hoping for, has not been implemented in a
way that you are hoping for, then probably no-one cared enough to ensure
that it was done in that way.
> I thought such a "feature" would be in Nginx by now, if not devised by
> developers than included by popular demand - looking at the options/params
> to 'listen', something like 'remain' or 'insist' which would instruct Nginx
> to start & continue to work and hook onto the IP when/after it appeared(but
> also continue to work after IP disappeared)
As Maxim indicates in the parallel reply: nginx will not fail if it does
not try to bind() to a non-existing address:port.
And you can arrange that, by making sure that your "listen ip:port"
directive does not include any of the parameters that require a bind();
and by making sure that, for each port that you listen on, there is also a
"listen *:port"-equivalent directive somewhere in the config.
So possibly the feature that you want already exists with restrictions
that you are happy to work within?
Cheers,
f
--
Francis Daly francis at daoine.org
On 13/02/2022 11:24, Francis Daly wrote:
> On Sun, Feb 13, 2022 at 07:56:16AM +0000, lejeczek via nginx wrote:
>> On 12/02/2022 13:26, Francis Daly wrote:
>>> On Sat, Feb 12, 2022 at 10:11:25AM +0000, lejeczek via nginx wrote:
> Hi there,
>
>>>> having multiple 'listen' with IPs or, just one 'listen' with a hostname
>>>> which resolves to more than one IP - is it possible to tell Nginx not fail
>>>> when one of IPs is absent, does not exist?
>>> I think that stock nginx does not support that.
>>>
>>> There are possibly ways to avoid the failure; but they all fundamentally
>>> are different ways to do "only bind to locally-existing addresses".
>> I can confess I return to Nginx after long many years of a divorce and this
>> curious fact - if Nginx cannot do that - will be a surprise to me.
> Use cases tend to be addressed when a developer has the incentive to
> write the code.
>
> If the feature that you are hoping for, has not been implemented in a
> way that you are hoping for, then probably no-one cared enough to ensure
> that it was done in that way.
>
Which amazes me a bit - I'd think that in this age of
clouds/virtualization/containers etc. removing iface or IP
or both(even hot-plugin hardware) is something what must
happen often, if not daily - why people would not need that
'feature' and not think it's silly of Nginx to fail for that
reason? - amazes me.
Certainly this use case where IP does not exists - perhaps
different case would be where IP does exist but cannot be
bound to - should be allowed & easy to give to end users an
option to "bind" to such non-existent IP with
'continue/remain/insist' or however devel want to call.
I read people replies and think they thought it was about
'port' in my case, but I tried to make it clear it's the
IP/iface - so "*" does not address the issue I described.
many thanks, L.
>> I thought such a "feature" would be in Nginx by now, if not devised by
>> developers than included by popular demand - looking at the options/params
>> to 'listen', something like 'remain' or 'insist' which would instruct Nginx
>> to start & continue to work and hook onto the IP when/after it appeared(but
>> also continue to work after IP disappeared)
> As Maxim indicates in the parallel reply: nginx will not fail if it does
> not try to bind() to a non-existing address:port.
>
> And you can arrange that, by making sure that your "listen ip:port"
> directive does not include any of the parameters that require a bind();
> and by making sure that, for each port that you listen on, there is also a
> "listen *:port"-equivalent directive somewhere in the config.
>
> So possibly the feature that you want already exists with restrictions
> that you are happy to work within?
>
> Cheers,
>
> f
Hello,
I would give a try to 'net.ipv4.ip_nonlocal_bind' sysctl knob. Set it to
true and bind() won't fail.
Regards,
Igor.
On 12/02/2022 10:11, lejeczek via nginx wrote:
> Hi guys
>
> a novice here so go easy on me with this question:
>
> having multiple 'listen' with IPs or, just one 'listen' with a
> hostname which resolves to more than one IP - is it possible to tell
> Nginx not fail when one of IPs is absent, does not exist?
>
> many thanks, L.
>
> _______________________________________________
> nginx mailing list -- nginx at nginx.org
> To unsubscribe send an email to nginx-leave at nginx.org
On 03/08/2022 10:54, Igor Ippolitov wrote:
> Hello,
>
> I would give a try to 'net.ipv4.ip_nonlocal_bind' sysctl
> knob. Set it to true and bind() won't fail.
>
> Regards,
> Igor.
>
Does the trick for Nginx too!
wielkie! dzięki
L.
Hello!
On Wed, Aug 03, 2022 at 09:50:10AM +0100, lejeczek via nginx wrote:
> On 13/02/2022 11:24, Francis Daly wrote:
> > On Sun, Feb 13, 2022 at 07:56:16AM +0000, lejeczek via nginx wrote:
> >> On 12/02/2022 13:26, Francis Daly wrote:
> >>> On Sat, Feb 12, 2022 at 10:11:25AM +0000, lejeczek via nginx wrote:
> > Hi there,
> >
> >>>> having multiple 'listen' with IPs or, just one 'listen' with a hostname
> >>>> which resolves to more than one IP - is it possible to tell Nginx not fail
> >>>> when one of IPs is absent, does not exist?
> >>> I think that stock nginx does not support that.
> >>>
> >>> There are possibly ways to avoid the failure; but they all fundamentally
> >>> are different ways to do "only bind to locally-existing addresses".
> >> I can confess I return to Nginx after long many years of a divorce and this
> >> curious fact - if Nginx cannot do that - will be a surprise to me.
> > Use cases tend to be addressed when a developer has the incentive to
> > write the code.
> >
> > If the feature that you are hoping for, has not been implemented in a
> > way that you are hoping for, then probably no-one cared enough to ensure
> > that it was done in that way.
> >
> Which amazes me a bit - I'd think that in this age of
> clouds/virtualization/containers etc. removing iface or IP
> or both(even hot-plugin hardware) is something what must
> happen often, if not daily - why people would not need that
> 'feature' and not think it's silly of Nginx to fail for that
> reason? - amazes me.
>
> Certainly this use case where IP does not exists - perhaps
> different case would be where IP does exist but cannot be
> bound to - should be allowed & easy to give to end users an
> option to "bind" to such non-existent IP with
> 'continue/remain/insist' or however devel want to call.
>
> I read people replies and think they thought it was about
> 'port' in my case, but I tried to make it clear it's the
> IP/iface - so "*" does not address the issue I described.
It is not clear why "*" does not address the issue you've
described. You may want to be more specific. In particular,
please explain why
listen *:80;
listen 99.99.99.99:80;
does not work for you.
The only case I can imagine is when you are not allowed to listen
on *:80 for some reason, and have to listen only on specific IP
addresses instead. This looks quite uncommon though, and usually
instead suggests that IP addresses are perfectly fixed.
(See description of the "bind" parameter of the "listen" directive
at http://nginx.org/r/listen for additional details.)
--
Maxim Dounin
http://mdounin.ru/