Welcome! Log In Create A New Profile

Advanced

Re: Listen on transient address

Maxim Dounin
November 16, 2018 06:42AM
Hello!

On Thu, Nov 15, 2018 at 11:59:31AM -0800, Roger Fischer wrote:

> I have an NGINX instance that listens on a tunnel (and some
> other interfaces). When NGINX was restarted while the tunnel was
> down (tun device and address did not exist), NGINX failed to
> start.
>
> [emerg] 1344#1344: bind() to 38.88.78.19:443 failed (99: Cannot
> assign requested address)
>
> Relevant config:
>
> listen 172.16.200.5:80 default_server;
> listen 38.88.78.19:80 default_server; # tunnel, not always
> up
>
> Is there a way to configure NGINX to listen “best effort”, still
> start even if it can’t bind to the address/port, and
> periodically retry to bind to the address/port? This would be my
> preferred solution.

If you want to bind nginx on addesses which are not yet available
on the host, the best solution is to configure a listening socket
on the wildcard address:

listen 80;

Further, if for some reason you want to restrict a particular
server only to connections to a particular IP address, you can do
so in additional to the lisening socket on the IP address. That
is, configure something like this:

server {
listen 80;
...
}

server {
listen 38.88.78.19:80;
...
}

With this configuration nginx will bind only on *:80, yet
connections to 38.88.78.19:80 will be handled in the second
server, much like with separate listening sockets.

See the description of the "bind" parameter of the "listen"
directive (http://nginx.org/r/listen) for additional details.

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Listen on transient address

Roger Fischer November 15, 2018 03:00PM

Re: Listen on transient address

Ashish SHUKLA November 16, 2018 03:02AM

Re: Listen on transient address

Maxim Dounin November 16, 2018 06:42AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 275
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready