Location "default" documentation

I had some trouble setting the “deferred” option on a listen
directive, related to the use of “default”. If someone can help me
understand this better, I’ll update the English documentation.

Our configuration has many server blocks, which look like the example
below. My first attempt was to append “deferred” to all of the listen
lines. This resulted in the error: ‘“deferred” parameter can be
specified for the default “listen” directive only’. My second attempt
was to put “deferred” only on the first entry in each server block,
thinking it was the implicit default. Same error. When explicitly
specifying the default, as in “listen 1.2.3.4:80 default deferred;” in
each server block, all’s well.

Two questions:

  1. Is this setting “deferred” for all of the listen directives in the
    server block? If not, how can this be done?
  2. What does “default” actually do? The docs for listen say:

‘If the directive has the “default” parameter, then the enclosing
server {…} block will be the default server for the address:port
pair. If there are no directives with the “default” parameter, then
the default server will be the first server in which the address:port
pair appears.’

This suggests multiple server blocks can have the same address:port,
with one server block being the default. I can imagine a use for the
with wildcard addresses, but not with explicit addresses. And I’m
left wondering how to set all sockets to deferred.

Thanks,
James

server {
listen 1.2.3.4:80;
listen 5.6.7.8:80;

}
server {
listen 1.2.3.4:443;
listen 5.6.7.8:443;

}

On Tue, Jan 13, 2009 at 09:40:10PM -0800, James Byers wrote:

I had some trouble setting the “deferred” option on a listen
directive, related to the use of “default”. If someone can help me
understand this better, I’ll update the English documentation.

Our configuration has many server blocks, which look like the example
below. My first attempt was to append “deferred” to all of the listen
lines. This resulted in the error: ‘“deferred” parameter can be
specified for the default “listen” directive only’.

Because “deferred” requires explicit “default” keyword.

My second attempt
was to put “deferred” only on the first entry in each server block,
thinking it was the implicit default. Same error.

As above.

When explicitly
specifying the default, as in “listen 1.2.3.4:80 default deferred;” in
each server block, all’s well.

Two questions:

  1. Is this setting “deferred” for all of the listen directives in the
    server block? If not, how can this be done?

No, “deferred” is property of listen socket, but of server block.
Several server blocks can share some listen socket.

with wildcard addresses, but not with explicit addresses.
server {
listen 1.2.3.4:80;
server_name one;
}

   server {
       listen       1.2.3.4:80;
       server_name  two;
   }

And I’m left wondering how to set all sockets to deferred.

You need to set

 listen ADDRESS:PORT default deffered;

once for each ADDRESS:PORT.

On Wed, Jan 14, 2009 at 6:01 AM, Igor S. [email protected] wrote:

  }

“server_name” suggests the first server block in configuration file
order will be used for non-matching hostnames. In the above listing
(modified to include “default” in the second server), will a request
for hostname “three” / IP 1.2.3.4 be handled by the second server
block or the first?

And I’m left wondering how to set all sockets to deferred.

You need to set

listen ADDRESS:PORT default deffered;

once for each ADDRESS:PORT.

Thanks for the clarification. Will update the wiki for both cases.

James

On Wed, Jan 14, 2009 at 08:33:47AM -0800, James Byers wrote:

      server_name  two;
  }

“server_name” suggests the first server block in configuration file
order will be used for non-matching hostnames. In the above listing
(modified to include “default” in the second server), will a request
for hostname “three” / IP 1.2.3.4 be handled by the second server
block or the first?

Non-matching hostnames are handled in server which has “listen” marked
as “default” for given address:port, i.e. hostname “three” / IP 1.2.3.4
will be handled by the second server block.