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.
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 ?
## 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 ~*
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.comwww.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/;
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.
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 ~*
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.
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 ~*
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?
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”.
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.
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.
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?
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.