Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have lots of subdomain in a server. Every subdomain has its own Drupal boost rules, like in below codes:

server {
    server_name  subdomain1.website.com;
    location / {
        root   /var/www/html/subdomain/subdomain1.website.com;
        index  index.php;
        set $boost "";
        set $boost_query "_";
        if ( $request_method = GET ) {
          set $boost G;
        }
        if ($http_cookie !~ "DRUPAL_UID") {
          set $boost "${boost}D";
        }
        if ($query_string = "") {
          set $boost "${boost}Q";
        }  
        if ( -f $document_root/cache/normal/$host$request_uri$boost_query.html ) {
          set $boost "${boost}F";
        }
        if ($boost = GDQF){
          rewrite ^.*$ /cache/normal/$host/$request_uri$boost_query.html break;
        } 
        if (!-e $request_filename) {
          rewrite  ^/(.*)$  /index.php?q=$1  last;
          break;
        }
    }
    location ~ \.php$ {
            fastcgi_pass    127.0.0.1:9000;
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME /var/www/html/subdomain/subdomain1.website.com$fastcgi_script_name;
            include         fastcgi_params;
    }
}

I adding all subdomain rules manually from time to time. The size of ngin.conf has become too big.

So,

I need one nginx rules which do:

subdomain1.website.com pointing to /var/www/html/subdomain/subdomain1.website.com
subdomain2.website.com pointing to /var/www/html/subdomain/subdomain2.website.com
subdomain3.website.com pointing to /var/www/html/subdomain/subdomain3.website.com

...and so on

(So that no more adding rules for subdomain .website.com I need in the future.)

share|improve this question
add comment

1 Answer

You need to use paths like a

root   /var/www/html/subdomain/$host;
fastcgi_param   SCRIPT_FILENAME /var/www/html/subdomain/$host$fastcgi_script_name;
share|improve this answer
add comment

Your Answer

 
discard

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