Server_name "";

we are running 0.7.64

have this as a server:

server
{
   server_name “”;

   location /
   {
       return 404;
   }
}

when we try to startup we get:

 [emerg]: the first server name must not be empty in
/ah/conf/nginx/default_server.conf:4

wiki says:

Since nginx 0.7.12, an empty server name is supported, to catch the
requests without “Host” header:

server {
server_name “”;
}

is the wiki wrong?

if yes and i want to have a server that returns nothing if there isnt
matching a hostname, how
do I do that?

On 19.12.2009, at 1:14, Sean A. wrote:

    return 404;

Since nginx 0.7.12, an empty server name is supported, to catch the
requests without “Host” header:

server {
server_name “”;
}

We use the underscore + listen default.

server
{
server_name _;
listen 80 default;
location / { return 404; }
}

On Fri, Dec 18, 2009 at 5:51 PM, Peter L. [email protected] wrote:

  location /
wiki says:
server
{
    server_name _;
    listen 80 default;
    location / { return 404; }
}

That works except, it is getting blocked by another and I’m not sure
why.
I’m doing this on a local network right now and m.example.com is
192.16.8.1.125
if m.example.com is setup then this doesn’t get used.

m.example.com has:

server
{
listen m.example.com;
server_name m.example.com;
}

So from the wiki,
if I do a request not to m.example.com but 192.168.1.125
shouldnt the listen 80 default server block be the one that handles
the response?

On Fri, Dec 18, 2009 at 3:04 PM, Sean A.
[email protected] wrote:

if m.example.com is setup then this doesn’t get used.
if I do a request not to m.example.com but 192.168.1.125
shouldnt the listen 80 default server block be the one that handles
the response?


nginx mailing list
[email protected]
nginx Info Page

FYI Igor’s latest documents at:
How nginx processes a request suggest the
following configuration:

server {
listen 80 default_server;
server_name _;
return 444;
}

You will note that now we use default_server, the server_name _, and
no need for a location to hold the return code.

– Merlin

On Fri, Dec 18, 2009 at 8:38 PM, merlin corey [email protected]
wrote:

  server_name “”;
/ah/conf/nginx/default_server.conf:4
We use the underscore + listen default.
I’m doing this on a local network right now and m.example.com is 192.16.8.1.125
So from the wiki,
FYI Igor’s latest documents at:
no need for a location to hold the return code.

I’m running 0.7.64 and after switching ‘default_server’ to default per
the wiki doc you referenced,
this still doesnt work. It doesnt respond as the default server

i have

m.example.com is still answering when you

wget http://192.168.1.125/

2009/12/19 Igor S. [email protected]:

when we try to startup we get:
 server_name “”;

  server_name m.example.com;
nginx Info Page
}
m.example.com is still answering when you

wget http://192.168.1.125/

Have you looked this:
Server names
How nginx processes a request

Yes.

Question as this isnt clear to me.

If I have a server

server
{
listen m.example.com;
server_name m.example.com;
}

and m.example.com is 192.168.1.125

and i also have

server
{
listen 80
server_name _;
}

which one should handle a request w/o a hostname to 192.168.1.125?

On Sat, Dec 19, 2009 at 02:15:55PM -0500, Sean A. wrote:

have this as a server:

server {
}
š šlisten m.example.com;
[email protected]
š šreturn š š š 444;

and m.example.com is 192.168.1.125

and i also have

server
{
listen 80
server_name _;
}

which one should handle a request w/o a hostname to 192.168.1.125?

It will be handled by default server.


Igor S.
http://sysoev.ru/en/

2009/12/19 Igor S. [email protected]:

we are running 0.7.64
  }
requests without “Host” header:
    listen 80 default;
server


  listen    80  default_server;

}

which one should handle a request w/o a hostname to 192.168.1.125?

It will be handled by default server.

this one?

server
{
listen 80 default;
server_name _;
return 444;
}

because that isn’t what is happening for me and i have a really basic
setup right now
as we are starting over with a new system and i’m building up from
simple stuff.

the default server for me answers on all interfaces except
192.168.1.125 for which

wget 192.168.1.125

is being handled by m.example.com

On Sat, Dec 19, 2009 at 02:28:06PM -0500, Sean A. wrote:

š š š š return 404;
Since nginx 0.7.12, an empty server name is supported, to catch the
š š š šserver_name _;

server {
this still doesnt work. It doesnt respond as the default server

server_name m.example.com;
}
listen 80 default;

wget 192.168.1.125

is being handled by m.example.com

Here you have two default servers:

server {
listen m.example.com; # default for 192.168.1.125:80

server {
listen 80 default; # default for *:80

You need to add

server {
listen m.example.com default;
server_name _;
return 444;
}


Igor S.
http://sysoev.ru/en/

On Sat, Dec 19, 2009 at 10:59:39AM -0500, Sean A. wrote:

{
š[emerg]: the first server name must not be empty in

That works except, it is getting blocked by another and I’m not sure why.

You will note that now we use default_server, the server_name _, and
wget http://192.168.1.125/
Have you looked this:
Server names
How nginx processes a request


Igor S.
http://sysoev.ru/en/

2009/12/19 Igor S. [email protected]:

On Fri, Dec 18, 2009 at 5:51 PM, Peter L. [email protected] wrote:

  location /
wiki says:
server

shouldnt the listen 80 default server block be the one that handles
following configuration:
I’m running 0.7.64 and after switching ‘default_server’ to default per
Server names
{
listen 80
server
the default server for me answers on all interfaces except

So if we have say 12 eth interfaces and I want to have a default
server for each I need to do:

server
{
listen 192.168.1.125 default;
server_name _;
return 444;
}

for each of them?

( except of course the ip address would change… )

On Sat, Dec 19, 2009 at 02:42:53PM -0500, Sean A. wrote:

On Fri, Dec 18, 2009 at 3:04 PM, Sean A. [email protected] wrote:

if m.example.com is setup then this doesn’t get used.
if I do a request not to m.example.com but 192.168.1.125
How nginx processes a request suggest the

Have you looked this:
server
{

š š listen m.example.com; # default for 192.168.1.125:80
š}
}

for each of them?

( except of course the ip address would change… )

Yes, if you have, for example, 192.168.1.125 and 192.168.1.130,
and you do not want to receive requests for m.example.com on
192.168.1.130.


Igor S.
http://sysoev.ru/en/

On Sat, Dec 19, 2009 at 02:41:10PM -0500, Sean A. wrote:

On 19.12.2009, at 1:14, Sean A. wrote:

š š {

{
m.example.com has:
the response?

the wiki doc you referenced,
How nginx processes a request
listen m.example.com;
server_name _;
{
192.168.1.125 for which
listen www.example.com;
if ( $uri ~ ^/maintenance/ )

location ~ /favicon.(ico|gif)$ { return 404; }


location /
{
    expires 7d;

}

}

nginx does not support PUT/DELETE by default.
Why not use clear try_files instead of these ugly maintenance
if/set/rewrites:

server
{
listen www.example.com;
server_name www.example.com;

 root /ah/sites/www.example.com/public;

 access_log /var/log/ah/www.example.com.log combined;

 location /
 {
     try_files   /maintenance/maintenance.html  $uri  =404;
     expires 7d;

 }

 location = /favicon.ico { return 404; }
 location = /favicon.gif { return 404; }

}

server 127.0.0.1:8383;
access_log /var/log/ah/m.example.com.log combined;
if ( $maintenance )
proxy_set_header Host $http_host;
}

location ~ ^/$
{
    index no;
    error_page 403 = @seaside;
}
 location = /
 {
     proxy_pass http://gemstone;
 }
    set $maintenance 1;
}    if ( $request_method = 'DELETE' ) { return 501; }
{        expires 7d;
    error_page 403 = @seaside;
listen 80 default;
server_name _;

location /
{
    return 404;
}

}


Igor S.
http://sysoev.ru/en/

On Sat, Dec 19, 2009 at 2:28 PM, Sean A.
[email protected] wrote:

    return 404;
Since nginx 0.7.12, an empty server name is supported, to catch the
    server_name _;

server {
this still doesnt work. It doesnt respond as the default server

server_name m.example.com;
}
  listen    80 default;

wget 192.168.1.125

is being handled by m.example.com

this is all the server blocks in order…

server
{
listen www.example.com;
server_name www.example.com;

root /ah/sites/www.example.com/public;

access_log /var/log/ah/www.example.com.log combined;
if ( -f $document_root/.maintenance )

{
set $maintenance 1;
}

if ( $uri ~ ^/maintenance/ )
{
set $maintenance 0;
}

if ( $maintenance )
{
rewrite (.*) /maintenance/maintenance.html;
}
if ( $request_method = ‘DELETE’ ) { return 501; }
if ( $request_method = ‘PUT’ ) { return 501; }

location ~ /favicon.(ico|gif)$ { return 404; }


location /
{
    expires 7d;

}

}

server
{
listen example.com;
server_name .example.com;

rewrite (.*) http://www.example.com$1 permanent;

}

upstream gemstone
{
server 127.0.0.1:8383;
}

server
{
listen m.example.com;
server_name m.example.com;

root /ah/sites/m.example.com/public;

access_log /var/log/ah/m.example.com.log combined;
if ( -f $document_root/.maintenance )
{
    set $maintenance 1;
}

if ( $uri ~ ^/maintenance/ )
{
    set $maintenance 0;
}

if ( $maintenance )
{
    rewrite (.*) /maintenance/maintenance.html;
}
if ( $request_method = 'DELETE' ) { return 501; }
if ( $request_method = 'PUT' ) { return 501; }

location ~ /favicon.(ico|gif)$ { return 404; }

proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_read_timeout 90;


location /
{        expires 7d;

    index index.html index.htm;
    try_files $uri $uri/ @seaside;
    error_page 403 = @seaside;
}

location ~ ^/$
{
    index no;
    error_page 403 = @seaside;
}

location @seaside
{
    proxy_pass http://gemstone;
}

}

server
{
listen m.example.com:443;
server_name m.example.com;

ssl                  on;
ssl_certificate      /ah/sites/m.example.com/conf/m.example.com.crt;
ssl_certificate_key  /ah/sites/m.example.com/conf/m.example.com.key;
ssl_ciphers          ALL:-ADH:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP;

root /ah/sites/m.example.com/public;

access_log /var/log/ah/m.example.com.log combined;    if ( -f

$document_root/.maintenance )
{
set $maintenance 1;
}

if ( $uri ~ ^/maintenance/ )
{
    set $maintenance 0;
}

if ( $maintenance )
{
    rewrite (.*) /maintenance/maintenance.html;
}    if ( $request_method = 'DELETE' ) { return 501; }
if ( $request_method = 'PUT' ) { return 501; }
location ~ /favicon.(ico|gif)$ { return 404; }
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_read_timeout 90;


location /
{        expires 7d;

    index index.html index.htm;
    try_files $uri $uri/ @seaside;
    error_page 403 = @seaside;

}

location ~ ^/$
{
    index no;
    error_page 403 = @seaside;
}

location @seaside
{
    proxy_pass http://gemstone;
}

}

server
{
listen 80 default;
server_name _;

location /
{
    return 404;
}

}

Why not use clear try_files instead of these ugly maintenance if/set/rewrites:

because /maintenance/maintenance.html always exists.

and it because the default that gets served based on the existence of
.maintenance in the document root.

nginx does not support PUT/DELETE by default.

as of what version?

On Sun, Dec 20, 2009 at 5:22 AM, Sean A.
[email protected] wrote:

Why not use clear try_files instead of these ugly maintenance if/set/rewrites:

because /maintenance/maintenance.html always exists.

and it because the default that gets served based on the existence of
.maintenance in the document root.

try_files /.maintenance $uri @fallback;

location = /.maintenance
{

}


O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

On Sat, Dec 19, 2009 at 9:19 PM, Edho P Arief [email protected]
wrote:

try_files /.maintenance $uri @fallback;

location = /.maintenance
{
 …
}

so locaiton = /.maintence rewrites to serving maintenance.html for
anything outside of /maintenance?

and @fallback would be?