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 have lots of subdomain in a server. Every subdomain has its own Drupal boost rules, like in below codes:

server {
    location / {
        root   /var/www/html/subdomain/;
        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;
    location ~ \.php$ {
            fastcgi_index   index.php;
            fastcgi_param   SCRIPT_FILENAME /var/www/html/subdomain/$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.


I need one nginx rules which do: pointing to /var/www/html/subdomain/ pointing to /var/www/html/subdomain/ pointing to /var/www/html/subdomain/

...and so on

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

share|improve this question

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

Your Answer


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