location "default" documentation

Igor Sysoev is at rambler-co.ru
Wed Jan 14 17:01:13 MSK 2009


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.

> 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.

       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.

> 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;
>  ...
> }


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list