root /home/u1/domains/example.com;

location = /rss.xml {
  rewrite ^ /index.php?q=rss.xml;
}

location = /sitemap.xml {
  try_files $uri /index.php?q=sitemap.xml;
}

location / {
  location ^~ /system/files/ {
    fastcgi_pass unix:/var/run/php5-example.com.sock;
    log_not_found off;
  }

  location ^~ /sites/default/files/private/ {
    internal;
  }

  location ^~ /system/files_force/ {
    fastcgi_pass unix:/var/run/php5-example.com.sock;
    log_not_found off;
  }

  location ~* /imagecache/ {
    access_log off;
    expires 30d;
    try_files $uri @drupal;
  }

  location ~* /files/styles/ {
    access_log off;
    expires 30d;
    try_files $uri @drupal;
  }

  location ~* ^.+\.(?:css|cur|js|jpe?g|gif|htc|ico|png|html|xml|otf|ttf|eot|woff|svg)$ {
    access_log off;
    expires 30d;
    tcp_nodelay off;
  }

  location ~* ^.+\.(?:pdf|pptx?)$ {
    expires 30d;
    tcp_nodelay off;
  }

  location ^~ /help/ {
    location ~* ^/help/[^/]*/README\.txt$ {
      fastcgi_pass  unix:/var/run/php5-example.com.sock;
    }
  }

  location ~* ^(?:.+\.(?:htaccess|make|engine|inc|info|install|module|profile|po|pot|sh|.*sql|test|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
    return 404;
  }

  try_files $uri $uri/ @cache;
}

location @cache {
  if ($query_string ~ ".+") {
    return 405;
  }

  if ($http_cookie ~ "DRUPAL_UID" ) {
    return 405;
  } 

  if ($request_method !~ ^(GET|HEAD)$ ) {
    return 405;
  }

  error_page 405 = @drupal;
  expires 12h;
  add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
  try_files /cache/normal/$host/${uri}_.html /cache/perm/$host/${uri}_.css /cache/perm/$host/${uri}_.js /cache/$host/0$uri.html /cache/$host/0${uri}/index.html @drupal;
}

location @drupal {
  rewrite ^ /index.php;
}

location @drupal-no-args {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  include fastcgi_params;
  fastcgi_intercept_errors on;
  fastcgi_pass  unix:/var/run/php5-example.com.sock;
}

location ~ /\. {
  deny all;
}

location @empty {
  expires 30d;
}

location = /boost_stats.php {
  fastcgi_pass unix:/var/run/php5-example.com.sock;
}

location ~ \.php$ {
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $request_filename;
  fastcgi_intercept_errors on;
  fastcgi_pass  unix:/var/run/php5-example.com.sock;
}
