server_name "";
Sean Allen
sean at monkeysnatchbanana.com
Sat Dec 19 22:41:10 MSK 2009
On Sat, Dec 19, 2009 at 2:28 PM, Sean Allen <sean at monkeysnatchbanana.com> wrote:
> 2009/12/19 Igor Sysoev <igor at sysoev.ru>:
>> On Sat, Dec 19, 2009 at 02:15:55PM -0500, Sean Allen wrote:
>>
>>> 2009/12/19 Igor Sysoev <igor at sysoev.ru>:
>>> > On Sat, Dec 19, 2009 at 10:59:39AM -0500, Sean Allen wrote:
>>> >
>>> >> On Fri, Dec 18, 2009 at 8:38 PM, merlin corey <merlincorey at dc949.org> wrote:
>>> >> > On Fri, Dec 18, 2009 at 3:04 PM, Sean Allen <sean at monkeysnatchbanana.com> wrote:
>>> >> >> On Fri, Dec 18, 2009 at 5:51 PM, Peter Leonov <gojpeg at gmail.com> wrote:
>>> >> >>> On 19.12.2009, at 1:14, Sean Allen wrote:
>>> >> >>>
>>> >> >>>> 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 "";
>>> >> >>>> }
>>> >> >>>
>>> >> >>> We use the underscore + listen default.
>>> >> >>>
>>> >> >>> 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?
>>> >> >>
>>> >> >> _______________________________________________
>>> >> >> nginx mailing list
>>> >> >> nginx at nginx.org
>>> >> >> http://nginx.org/mailman/listinfo/nginx
>>> >> >>
>>> >> >
>>> >> > FYI Igor's latest documents at:
>>> >> > http://nginx.org/en/docs/http/request_processing.html 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.
>>> >>
>>> >> 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/
>>> >
>>> > Have you looked this:
>>> > http://nginx.org/en/docs/http/server_names.html#miscellaneous_names
>>> > http://nginx.org/en/docs/http/request_processing.html
>>> >
>>>
>>> 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?
>>
>> 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
>
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;
}
}
More information about the nginx
mailing list