全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 4274|回复: 6

关于nginx防盗连

[复制链接]
发表于 2010-9-17 15:50:15 | 显示全部楼层 |阅读模式
一般网上的文章.都是说最简易的防盗联方式是
  1. location ~* \.(gif|jpg|png|swf|flv)$ {
  2. valid_referers none blocked www.xxx.com xxx.com ;
  3. if ($invalid_referer) {
  4. return 403;
  5. }
  6. }
复制代码
我把此段话加进到nginx.conf的最下方.系统一直提示
Starting nginx: [emerg]: "location" directive is not allowed here in /usr/local/nginx/conf/nginx.conf:53
[FAILED]
的错误.请问这是啥原因?(nginx是自己编译的.不是一键安装包.使用完全正常)
发表于 2010-9-17 15:50:59 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2010-9-17 16:37:26 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
 楼主| 发表于 2010-9-17 17:18:31 | 显示全部楼层

回复 3# 的帖子

谢谢您的指导.已经照你说的放对了位置.但结果不起作用.把jpg图片贴到他站测试还是能显示.请问要开启啥功能或是哪里我没注意到?
发表于 2010-9-17 17:31:48 | 显示全部楼层
估计是缓存作用
 楼主| 发表于 2010-9-17 17:51:47 | 显示全部楼层
大哥.请赐教.原本的代码是
  1.   server
  2.   {
  3.     listen       80;
  4.     server_name  abc.com;
  5.     index index.html index.htm index.php;
  6.     root  /home/www/wwwroot;

  7.     location ~ .*\.php?$
  8.     {
  9.       fastcgi_pass  127.0.0.1:9000;
  10.       fastcgi_index index.php;
  11.       include fcgi.conf;
  12.     }

  13.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  14.     {
  15.       expires      30d;
  16.     }

  17.     location ~ .*\.(js|css)?$
  18.     {
  19.       expires      1h;
  20.     }

  21.     access_log  off;
  22.       }
复制代码
要实现防盗连.到底要放在哪里?请您放到正确位置.小弟受教了.谢谢
 楼主| 发表于 2010-9-17 19:46:49 | 显示全部楼层

回复 9# 的帖子

感谢这位大哥不厌其烦的教导.已成功.感谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-28 05:13 , Processed in 0.085396 second(s), 6 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表