drupal6里boost模块安装的nginx重写规则

匿名 (未验证), 8 七月, 2012


    location / {
        if (!-e $request_filename) {
             rewrite  ^/(.*)$  /index.php?q=$1  last;
        }
    }

改写为:

    location /boost-gzip-cookie-test.html {
        return 404;
    }

    location / {

###Nginx-BOOST
  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/$http_host$request_uri$boost_query$query_string.html ) {
    set $boost "${boost}F";
  }
  if ($boost = GDQF){
    rewrite ^.*$ /cache/normal/$http_host/$request_uri$boost_query$query_string.html break;
  }
  if ( -f $document_root/cache/perm/$http_host$request_uri$boost_query$query_string.css ) {
    set $boost "${boost}F";
  }
  if ($boost = GDQF){
    rewrite ^.*$ /cache/perm/$http_host/$request_uri$boost_query$query_string.css break;
  }
  if ( -f $document_root/cache/perm/$http_host$request_uri$boost_query$query_string.js ) {
    set $boost "${boost}F";
  }
  if ($boost = GDQF){
    rewrite ^.*$ /cache/perm/$http_host/$request_uri$boost_query$query_string.js break;
  }
  ###END-BOOST

        if (!-e $request_filename) {
             rewrite  ^/(.*)$  /index.php?q=$1  last;
        }
    }
 

其中boost-gzip-cookie-test.html的404错误似乎是boost模块的bug(参看官网的讨论),由于drupal的404页面相当耗资源,所以干脆在nginx直接返回个404算了。

评论