server {} 里加入以下内容:


location ~* \.(gif|jpg|png|swf|flv)$ {
    valid_referers none blocked www.test.com *.test.com;
    if ($invalid_referer) {
        return 403;
    }
}