让nginx的expires和防盗链都有效

xxuyuan 2011-07-02

expires有效,防盗链失效

location ~* ^.+\.(jpg|jpeg|gif|png|css|js|swf)$ {
  access_log off;
  root /opt/app/xuexi6;
  expires 1h;
  #break;
}

location ~* ^.+\.(jpg|jpeg|gif|png|swf|rar|zip)$ {
  valid_referers none blocked *.xuexi6.com;
  if ($invalid_referer) {
    rewrite ^/ http://www.xuexi6.com/404.gif;
    return 412;
  }
}

只有js和css的expire有效,防盗链有效

location ~* ^.+\.(jpg|jpeg|gif|png|swf|rar|zip)$ {
  valid_referers none blocked *.xuexi6.com;
  if ($invalid_referer) {
    rewrite ^/ http://www.xuexi6.com/404.gif;
    return 412;
  }
}

location ~* ^.+\.(jpg|jpeg|gif|png|css|js|swf)$ {
  access_log off;
  root /opt/app/xuexi6;
  expires 1h;
  #break;
}

expire和防盗链都有效

location ~* ^.+\.(jpg|jpeg|gif|png|swf|rar|zip|css|js)$ {
  valid_referers none blocked *.xuexi6.com;
  if ($invalid_referer) {
    rewrite ^/ http://www.xuexi6.com/404.gif;
    return 412;
  }
  access_log off;
  root /opt/app/xuexi6;
  expires 1h;
  break;
}

相关推荐