server

{

    listen 80;

    server_name www.test1.com www.aaa1.com www.bbb1.com;

    if ($host != 'www.test1.com')

      {

   rewrite ^/(.*)$ http://www.test1.com/$1 permanent;

     }

    index index.html index.htm index.php;

    root /data/www;

     access_log /tmp/access.log 123123;

    location ~ .*admin\.php$ {

       auth_basic "123123 auth";

      auth_basic_user_file /usr/local/nginx/conf/.htpasswd;

 include fastcgi_params;

        fastcgi_pass unix:/tmp/www.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

}

 *  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|rar|zip||gz|bz2)$

      {

    access_log off;

expires 30d;  

 *valid_referers none blocked server_names *.test1.com *.aaa1.com

*if ($invalid_referer)

 *{

 * return 403;

  

* }

   }

location ~ .*\.(js|css)

access_log off; 

expires 12h; 

}

   location ~ .*\.(static|cache)$

       {

    access_log off;

    }

    location ~ \.php$ {

        include fastcgi_params;

        fastcgi_pass unix:/tmp/www.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;

    }


}


测试

curl -e "http://www.baidu.com/123 -I x127.0.0.1:80 ‘图片地址’