Conflicting server name - i don't understand

Hi, i have a strange problem, I configured two vhosts files but when i
start nginx it gives the following error although the two vhosts are
configured correctly, almost identical (except domain names). When I
remove one vhost everything is ok. In both vhosts file server name is
set, i don’t understand what kind of conflicting server name could
possibly be. I also added this to one of the vhost, no change
whatsoever, the same errro appears

server {
server_name _; #default
return 444;
}

Starting nginx: : conflicting server name “ubuntu” on 0.0.0.0:80,
ignored
nginx.

Maybe i’m missing something, i don’t know

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,5464,5464#msg-5464

This is my vhost file.Basically for every vhost i just copy this and
change domain name. What i’m missing here, why if i add the second vhost
it gives me that error ?

server {
listen 80;
server_name www.xxx.com;

  #redirect www to non-www
        rewrite ^/(.*) http://xxx.com/$1 permanent;


   }

server {
listen 80;
server_name xxx.com;
access_log /home/xxx/log/access.log;
error_log /home/xxx/log/error.log;

        location /  {
    root   /home/xxx/public_html/;
    index  index.php index.html;
    expires 30d;

    #stop image and files hotlinking
    location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip|jpeg|css)$ {
    valid_referers none blocked xxx.com www.xxx.com *.google.com 

*.yahoo.com;
if ($invalid_referer) {
return 444;
}
}

    #joomla sef url's
    if (!-e $request_filename) {
      rewrite  ^(.*)$  /index.php?q=$1  last;
      break;
            }
      }

    if ( $args ~ "mosConfig_{1,21}(=|\%3d)" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }

    if ( $args ~ "base64_encode.*\(.*\)" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }

    if ( $args ~ "(\<|%3C).*script.*(\>|%3E)" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }

    if ( $args ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }

    if ( $args ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }


        # pass the PHP scripts to FastCGI server listening on 

127.0.0.1:9000
location ~ .php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME
/home/xxx/public_html/$fastcgi_script_name;
}
}

server {

  ## Only allow GET and HEAD request methods
  if ($request_method !~ ^(GET|HEAD)$ ) {
  return 444;
  }
  ## Deny illegal Host headers
  if ($host !~* ^(xxx.com|www.xxx.com)$ ) {
  return 444;
  }
  ## Deny certain User-Agents (case insensitive)
  ## The ~* makes it case insensitive as opposed to just a ~
  if ($http_user_agent ~* (Baiduspider) ) {
  return 444;
  }

  ## Deny certain Referers (case insensitive)
  ## The ~* makes it case insensitive as opposed to just a ~
  if ($http_referer ~* 

(babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo)
) {
return 444;
}

  ## Serve an empty 1x1 gif _OR_ an error 204 for favicon.ico
  location = /favicon.ico {
  #empty_gif;
  return 204;
  }


  ## All other errors get the generic error page
  error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 

414 415 416 417
500 501 502 503 504 505 /error_page.html;
location /error_page.html {
internal;

 }

}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,5464,5465#msg-5465

server {
    server_name  _;  #default
    return 444;
  }

Where’s the other server? How ‘bout posting your servers’ full
configuration?

I’m no expert, but may’be thi’ll help…

On Tue, Sep 1, 2009 at 22:51, ktm[email protected] wrote:

This is my vhost file.Basically for every vhost i just copy this and change domain name. What i’m missing here, why if i add the second vhost it gives me that error ?

You have 3 servers{ }, not 2.

 server {
      listen  80;
      server_name  www.xxx.com;
[…]
   }

You can erase this one, and just use server_name xxx.com www.xxx.com;
in your next server entry:

server {
            listen  80;
            server_name xxx.com; # <-- replace
[…]

The way you have it, you have two servers for the same domain. If i’m
not mistaken, that doesn’t work correctly (and is unnecessary), unless
one server is taking incoming requests and the other is one of the
backend servers (thus using nginx’s reverse proxy thingy).

      location /  {
                root  /home/xxx/public_html/;

Are you making vhosts for the local users? something like
http://xxx.com/~username/ ? If so, did you check permissions?

There are a lot of ifs, maybe some can be replaced. Which version are
you running? Did you compile from source (if so with which parameters)
of install from a package? Which OS? If all else fails, you can start
with very basic configurations for your servers and add from there.

HTH,
Nuno Magalhães

On Tue, Sep 01, 2009 at 05:51:19PM -0400, ktm wrote:

    return 444;
    if ( $args ~ "mosConfig_{1,21}(=|\%3d)" ) {

    }
              {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        include /usr/local/nginx/conf/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /home/xxx/public_html/$fastcgi_script_name;
                    }
   }

server {

This server has no server_name, it will be “hostname” byt default.

  ## Only allow GET and HEAD request methods
  if ($request_method !~ ^(GET|HEAD)$ ) {
  return 444;
  }
  ## Deny illegal Host headers
  if ($host !~* ^(xxx.com|www.xxx.com)$ ) {
  return 444;
  }

Instead of “if ($host !~* ^(xxx.com|www.xxx.com)$ )” you should set all
server’s {} with server_names and add yet another default one:

server {
server_name _; return 444;
}

Nuno Magalhães wrote:

server {

backend servers (thus using nginx’s reverse proxy thingy).

You are mistaken. I run most all of my domains as:

server {
listen 80;
server_name domain.com;
[snip]
}

server {
listen 80;
server_name www.domain.com;
rewrite ^ http://domain.com$request_uri? permanent;
}

This does not generate any errors.

(Yes, I also don’t like the www prefix.)

This also is exactly how Igor suggested that I do it.

If I have SSL enabled, then there are two more servers for the same
domain.

But even if I didn’t do it that way I would still use separate servers
for 80 and 443 for the same domain.

of install from a package? Which OS? If all else fails, you can start
with very basic configurations for your servers and add from there.

HTH,
Nuno Magalhães

Jim

I think i got it, i misunderstood you Igor, i just created a default
vhost with below code, strip down the other vhosts, and put server names
for all.Now it’s working fine.

(I know it seems I’m talking to myself on nginx forum :), but I don’t
know where to reply, it seems that mail list response don’t appear here)

server {
server_name _;return 444;
## Only allow GET and HEAD request methods
if ($request_method !~ ^(GET|HEAD)$ ) {
return 444;
}
## Deny illegal Host headers
if ($host !~* ^(digitalfav.com|www.digitalfav.com)$ ) {
return 444;
}
## Deny certain User-Agents (case insensitive)
## The ~* makes it case insensitive as opposed to just a ~
if ($http_user_agent ~* (Baiduspider) ) {
return 444;
}

  ## Deny certain Referers (case insensitive)
  ## The ~* makes it case insensitive as opposed to just a ~
  if ($http_referer ~* 

(babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo)
) {
return 444;
}

  ## Serve an empty 1x1 gif _OR_ an error 204 for favicon.ico
  location = /favicon.ico {
  #empty_gif;
  return 204;
  }


  ## All other errors get the generic error page
  error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 

414 415 416 417
500 501 502 503 504 505 /error_page.html;
location /error_page.html {
internal;

 }

}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,5464,5468#msg-5468

I don’t know what’s happening here, i’m posting at the nginx forums and
I saw the responses on some mailing list by mistake and not at the
forums. I’m not really sure if nginx forum is integrated with mailing
list or maybe i understand wrong.

Anyway if i add this
server_name_;return 444;

to one vhost , it works fine, no errors

Is this configuration ok Igor ? Those if’s are rewrites of joomla
.htaccess file. Also do i need to put server_name_;return 444; to every
vhost or just to one vhost is enough ? It seems that nginx give no
errors if I just add to one vhost.I use nginx 0.7.61.

Thank you for your help

server {
listen 80;
server_name www.digitalfav.com;

  #redirect www to non-www
        rewrite ^/(.*) http://digitalfav.com/$1 permanent;


   }

server {
listen 80;
server_name digitalfav.com;
access_log /home/digitalfav/log/access.log;
error_log /home/digitalfav/log/error.log;

        location /  {
    root   /home/digitalfav/public/;
    index  index.php index.html;
    expires 30d;

    #stop image and files hotlinking
    location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip|jpeg|css)$ {
    valid_referers none blocked digitalfav.com www.digitalfav.com 

*.google.com *.yahoo.com;
if ($invalid_referer) {
return 444;
}
}

    #joomla sef url's
    if (!-e $request_filename) {
      rewrite  ^(.*)$  /index.php?q=$1  last;
      break;
            }
      }

    if ( $args ~ "mosConfig_{1,21}(=|\%3d)" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }

    if ( $args ~ "base64_encode.*\(.*\)" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }

    if ( $args ~ "(\<|%3C).*script.*(\>|%3E)" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }

    if ( $args ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }

    if ( $args ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ) {
    set $args "";
    rewrite ^.*$ http://$host/index.php last;
    return 403;
    }


        # pass the PHP scripts to FastCGI server listening on 

127.0.0.1:9000
location ~ .php$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include /usr/local/nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME
/home/digitalfav/public_html/$fastcgi_script_name;
}
}

server {
server_name_;return 444
## Only allow GET and HEAD request methods
if ($request_method !~ ^(GET|HEAD)$ ) {
return 444;
}
## Deny illegal Host headers
if ($host !~* ^(digitalfav.com|www.digitalfav.com)$ ) {
return 444;
}
## Deny certain User-Agents (case insensitive)
## The ~* makes it case insensitive as opposed to just a ~
if ($http_user_agent ~* (Baiduspider) ) {
return 444;
}

  ## Deny certain Referers (case insensitive)
  ## The ~* makes it case insensitive as opposed to just a ~
  if ($http_referer ~* 

(babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo)
) {
return 444;
}

  ## Serve an empty 1x1 gif _OR_ an error 204 for favicon.ico
  location = /favicon.ico {
  #empty_gif;
  return 204;
  }


  ## All other errors get the generic error page
  error_page 400 401 402 403 404 405 406 407 408 409 410 411 412 413 

414 415 416 417
500 501 502 503 504 505 /error_page.html;
location /error_page.html {
internal;

 }

}

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,5464,5467#msg-5467

This does not generate any errors.
Glad to hear it.

(Yes, I also don’t like the www prefix.)
Do you have a specific reason for using two server{ } for the same
domain? Other than

This also is exactly how Igor suggested that I do it.

But even if I didn’t do it that way I would still use separate servers for
80 and 443 for the same domain.

Does the listen directive accept multiple values? Or does the server
accept multiple listen directives? The latter seems to be true
according to the wiki, so why the separation?

Nuno Magalhães wrote:

This also is exactly how Igor suggested that I do it.

Yes. If I recall correctly, it came about when I posted a site
configuration for another reason. At the time I was using an “if” clause
to rewrite “www.domain.com” to “domain.com”.

It probably went something like:

http://wiki.nginx.org/NginxHttpRewriteModule#ifif ($host ~*
www.(.)) {
http://wiki.nginx.org/NginxHttpRewriteModule#setset
$host_without_www $1;
rewrite http://wiki.nginx.org/NginxHttpRewriteModule#rewrite ^(.
)$
http://wiki.nginx.org/NginxHttpCoreModule#http
http://$host_without_www$1 permanent;
}

Again, if I recall correctly, Igor suggested that using a separate
server entry with a rewrite and eliminating the “if” clause would be far
more efficient. It’s been far too many years than I care to admit (but
perhaps near if not greater than the median age on this mailing list)
since I mucked around in C so who am I to argue?

But even if I didn’t do it that way I would still use separate servers for
80 and 443 for the same domain.

Does the listen directive accept multiple values? Or does the server
accept multiple listen directives?

I don’t know. Never tried.

The latter seems to be true
according to the wiki, so why the separation?

Cleaner. Easier to edit and follow. Easier to cut and paste when
creating new domains. Probably more style than substance though. :slight_smile:

Jim

ktm Wrote:

I don’t know what’s happening here, i’m posting at
the nginx forums and I saw the responses on some
mailing list by mistake and not at the forums. I’m
not really sure if nginx forum is integrated with
mailing list or maybe i understand wrong.

The incoming (POP3) mail imported stopped working for some reason.

Sorry about that.

I believe that I have it fixed now.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,5498,5524#msg-5524

On Wed, Sep 02, 2009 at 06:06:34PM -0400, Jim O. wrote:

domain? Other than

Again, if I recall correctly, Igor suggested that using a separate
server entry with a rewrite and eliminating the “if” clause would be far
more efficient. It’s been far too many years than I care to admit (but
perhaps near if not greater than the median age on this mailing list)
since I mucked around in C so who am I to argue?

Yes, you are right. This was from the very start.

On Wed, Sep 02, 2009 at 08:47:39AM +0100, Nuno Magalh??es wrote:

But even if I didn’t do it that way I would still use separate servers for
80 and 443 for the same domain.

Does the listen directive accept multiple values? Or does the server
accept multiple listen directives? The latter seems to be true
according to the wiki, so why the separation?

There can be several “listen” directive in one server. You can even
use HTTPS/HTTP site in single server:

server {
listen 80;
listen 443 default ssl;

ssl_certificate ...
ssl etc.

if these sites has very little difference.
However, it’s better to separate them for future administration relief
and “include” common parts.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs