Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to figure out why a subdomain I just created in Nginx isn't using the root folder specified in it's configuration file. Below is the config file for the subdomain zeta.

server {
    listen   80; 

    root /var/www/zeta;
    error_log  /var/log/nginx/subdomains_error.log;
    error_page 404 /404.html;
    if ($subdomain = ""){
        set $subdomain something;
        rewrite /.* /not_found;
    location / {
        index index.php index.html index.htm;
        access_log  /var/log/nginx/subdomains_access.log;
        location / {
            include        fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root/index.php;
            access_log  /var/log/nginx/subdomains_php_access.log;

        location /public {
        location ~ \.(js|ico|gif|jpg|png|css)$ {
        location /not_found {
        location /404.html {


I have another domain file which is setup to with a wildcard subdomain and different root folder see below it's the only difference

root /var/www/account;
server_name  *;

There's a text file in /etc/nginx called subdomains. A perl file reads the list of subdomains and if one exists it loads the page otherwise shows an error. I know that my wildcard subdomain file is picking up zeta as it's in the subdomains text file. It's setup like this because the server is an application and when visitors register we add their chosen subdomain to the file and reload Nginx without affecting users already on the site.

What changes can I make to the zeta file so that it'll use /var/www/zeta as the root folder and not the root folder in the wildcard config file?


share|improve this question

If that's a copy-paste of your nginx config, your issue is a typo here:


...that should presumably read zeta.

share|improve this answer
Just a typo here. I ended up copying another site config file which didn't have the if condition and it's working. – Anagio Oct 15 '12 at 12:15

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.