Forum: NGINX multy subdomain

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Andrius Semionovas (Guest)
on 2009-04-25 19:48
(Received via mailing list)
my configuration is:

server {
  listen       80;
  server_name  www.domain.com main.domain.com test.domain.com
hight.domain.com;

  if ($host = 'www.domain.com') {
    root /www/server;
    access_log   logs/www.domain.com.log  main;
  }
  if ($host = 'main.domain.com') {
    root /www/main;
    access_log   logs/main.domain.com.log  main;
  }
  if ($host = 'test.domain.com') {
    root /www/test;
    access_log   logs/test.domain.com.log  main;
  }
  if ($host = 'hight.domain.com') {
    root /www/hight;
    access_log   logs/hight.domain.com.log  main;
  }

  location / {
    index index.php index.html index htm;
  }
  location /banner/ {
    root /www/server;
    autoindex on;
  }
  location ~ .php$ {
    fastcgi_pass   unix:/wwwserver/php/socket;
    include fastcgi.conf;
  }
  location ~ phpinfo.php$ {
    allow   78.56.76.213;
    deny  all;
  }
  location ~ do((0[1-9])|([1-9][0-9])).php {
    allow   78.56.76.213;
    deny  all;
  }
  location = /nginx_status {
    stub_status on;
    access_log   off;
    allow 78.56.76.213;
    deny all;
  }
  location = /chat {
    rewrite ^/chat(.*)$ /chat.php$1 break;
    root /www/chat;
    fastcgi_pass   unix:/wwwserver/php/socket;
    include fastcgi-main.conf;
  }
  location /userbar/ {
    rewrite ^/userbar/(.*)\.png$ /userbar.php?id=$1 break;
    fastcgi_pass   unix:/wwwserver/php/socket;
    include fastcgi-main.conf;
  }
}

but i get error:

2009/04/25 18:28:04 [emerg] 15472#0: "root" directive is not allowed
here
in /server/nginx/conf/virtual/www.domain.com:15

I want, each subdomain will but run from /www/<sudomain_name , but i not
know how i can split adress into root, and if { root ****** } not work.
'IF' need but into location

Sorry for my bad english
Igor S. (Guest)
on 2009-04-25 20:08
(Received via mailing list)
On Sat, Apr 25, 2009 at 06:35:49PM +0300, Andrius Semionovas wrote:

>   }
>     access_log   logs/hight.domain.com.log  main;
>     fastcgi_pass   unix:/wwwserver/php/socket;
>   location = /nginx_status {
>   }
> in /server/nginx/conf/virtual/www.domain.com:15
>
> I want, each subdomain will but run from /www/<sudomain_name , but i not
> know how i can split adress into root, and if { root ****** } not work.
> 'IF' need but into location

server {
     server_name  www.domain.com;

     root /www/server;
     access_log   logs/www.domain.com.log  main;

     location / {
         ...
     }

     ...
}

server {
     server_name  main.domain.com;

     root /www/main;
     access_log   logs/main.domain.com.log  main;

     location / {
         ...
     }

     ...
}
This topic is locked and can not be replied to.