4

Here is the problem: I have two domains which have pointed to two available IPs on a server. Say:

siteone.com pointed to 1.2.3.4 sitetwo.com pointed to 1.2.3.5

What I did to configure nginx vhosts was to put

server {
        listen    site1.com:80; # 
        server_name   site1.com www.site1.com;

on vhost1 file and

server {
        listen    site2.com:80; # 
        server_name   site2.com www.site2.com;

on a (separate) vhost2 file. The two vhost files are exact replicates expect the site1 and site2 paths, of course. And vhost1 is working well on its own.

However after restarting nginx I get this error:

Restarting nginx: the configuration file /etc/nginx/nginx.conf syntax is ok [emerg]: bind() to 1.2.3.5:80 failed (99: Cannot assign requested address) configuration file /etc/nginx/nginx.conf test failed

When I put

server {
        listen   *:80; # 
        server_name   site2.com www.site2.com;

On site2 vhost, the nginx restarts without error but does not render pages on site2 path.

I'm confused and appreciate your help.

1 Answer 1

10

Try this:

server {
    listen    1.2.3.4:80; # 
    server_name   site1.com www.site1.com;
    ...
}

server {
    listen    1.2.3.5:80; # 
    server_name   site2.com www.site2.com;
    ...
}
8
  • You beat me to it! Sep 10, 2012 at 19:08
  • Do you mean putting both directives on vhost1 file?
    – alfish
    Sep 10, 2012 at 19:09
  • @alfish: no matter. You can put it in anywhere you want (as long as it is included in the main configuration file).
    – quanta
    Sep 10, 2012 at 19:17
  • 1
    After doing this, I get the same error:"Restarting nginx: the configuration file /etc/nginx/nginx.conf syntax is ok [emerg]: bind() to 1.2.3.5:80 failed (99: Cannot assign requested address)configuration file /etc/nginx/nginx.conf test failed" . How can I check that 1.2.3.5 is really usable, as my ISP claims?
    – alfish
    Sep 10, 2012 at 20:01
  • sudo /sbin/ip addr sh?
    – quanta
    Sep 10, 2012 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .