Francis,
Sorry it took so long, I’ve finally come back to this question.
The example you gave works great:
server {
listen 127.0.0.1:8088;
return 200 "listen 127.0.0.1:8088\n";
}
server {
listen 10.0.1.2:8088;
return 200 "listen 10.0.1.2:8088\n";
}
server {
listen 8088;
return 200 "listen 8088\n";
}
Where I get into problem is if I do something like this:
server {
listen 127.0.0.1:8088 backlog=65536 deferred;
return 200 "listen 127.0.0.1:8088\n";
}
server {
listen 10.0.1.2:8088 backlog=65536 deferred;
return 200 "listen 10.0.1.2:8088\n";
}
server {
listen 8088;
return 200 "listen 8088\n";
}
In that case I get errors like “nginx: [emerg] bind() to 0.0.0.0:8088
failed (98: Address already in use)”. So the workaround is obviously not
to
use those options - I could patch the source to use a backlog larger
then
511.
This example also works well:
server {
listen *:80;
server_name “test_a”;
return 200 “listen test_a”;
}
server {
listen *:80;
server_name “test_b”;
return 200 “listen test_b”;
}
server {
listen *:80 default_server;
return 200 “listen *”;
}
But if I change it to this:
server {
listen *:80 backlog=65536 deferred;
server_name “test_a”;
return 200 “listen test_a”;
}
server {
listen *:80 backlog=65536 deferred;
server_name “test_b”;
return 200 “listen test_b”;
}
server {
listen *:80 backlog=65536 deferred default_server;
return 200 “listen *”;
}
Then I get the error message “nginx: [emerg] duplicate listen options
for
0.0.0.0:80 in /etc/nginx/nginx.conf”. I can fix it by doing something
like
this:
server {
listen *:80;
server_name “test_a”;
return 200 “listen test_a”;
}
server {
listen *:80;
server_name “test_b”;
return 200 “listen test_b”;
}
server {
listen *:80 backlog=65536 deferred default_server;
return 200 “listen *”;
}
From the ss -l output I am picking up the larger listen queue which I’m
happy about, though its confusing why nginx is picking them from that
last
server stanza (it has the same behavior without the default_server
keyword). If I’m doing a virtual hosting type setup and I’m including
all
of my server definitions from individual files in a subdirectory, it
appears that any one of them could bump up the backlog, but if any two
server stanzas have options to do it then it causes an error. Maybe the
best way to do it is to have some sort of dummy entry that sets the
options
- if its always the last server stanza that sets the listen options then
maybe include all the other server stanzas and have the dummy at the
end
that sets the backlog and deferred options?