VPS侦探论坛

 找回密码
 注册
查看: 7666|回复: 7

求军哥看看我的防盗链代码到底错在哪里了。

[复制链接]
发表于 2012-7-19 18:30:06 | 显示全部楼层 |阅读模式

求军哥看看我的防盗链代码到底错在哪里了。

又要麻烦到你了,哈哈哈。。。我都有点不好意思了。

我修改的另一个域名:att.xxx.com.conf(在/usr/local/nginx/conf/vhost/下)
我没有修改默认的nginx.conf


修改完成后并重启lnmp,就出现服务器上所有的网站都无法打开的问题

  1. server
  2. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  3.                          {
  4.                                  valid_referers none blocked *.xxx.info *.xxx.com;
  5.                                  if ($invalid_referer) {
  6.                                  rewrite ^/ http://xx.ooo.info/ad/daolian.jpg;
  7.                                  #return 404;
  8.                                  }
  9. {
  10.   listen       80;
  11.   server_name att.xxx.com;
  12.   index index.html index.htm index.php default.html default.htm default.php;
  13.   root  /home/wwwroot/web;  include none.conf;
  14.   location ~ .*\.(php|php5)?$
  15.    {
  16.     fastcgi_pass  unix:/tmp/php-cgi.sock;
  17.     fastcgi_index index.php;
  18.     include fcgi.conf;
  19.    }

  20.   location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  21.    {
  22.     expires      30d;
  23.    }  location ~ .*\.(js|css)?$
  24.    {
  25.     expires      12h;
  26.    }  access_log off;
  27. }
复制代码


完成后会出现服务器上所有的网站都无法打开,
日志提示:

  1. 2012/07/19 18:15:15 [emerg] 2731#0: invalid number of arguments in "server" directive in /usr/local/nginx/conf/vhost/att.xxx.com.conf:3
复制代码

[ 本帖最后由 leexee 于 2012-7-19 18:33 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-7-19 18:47:00 | 显示全部楼层


  1. server
  2. {
  3.   listen       80;
  4.   server_name att.xxx.com;
  5.   index index.html index.htm index.php default.html default.htm default.php;
  6.   root  /home/wwwroot/web;  include none.conf;
  7.   location ~ .*\.(php|php5)?$
  8.    {
  9.     fastcgi_pass  unix:/tmp/php-cgi.sock;
  10.     fastcgi_index index.php;
  11.     include fcgi.conf;
  12.    }
  13. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  14. {
  15. valid_referers none blocked *.xxx.info *.xxx.com;
  16. if ($invalid_referer) {
  17. rewrite ^/ http://xx.ooo.info/ad/daolian.jpg;
  18. #return 404;
  19. }
  20. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  21.    {
  22.     expires      30d;
  23.    }
  24. location ~ .*\.(js|css)?$
  25.    {
  26.     expires      12h;
  27.    }
  28.   access_log off;
  29. }
复制代码
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2012-7-19 18:58:00 | 显示全部楼层

还是不行哦,,日志提示:

  1. 2012/07/19 18:49:10 [emerg] 3356#0: unexpected end of file, expecting "}" in /usr/local/nginx/conf/vhost/att.xxx.com.conf:27
复制代码


att.xxx.com.conf文件代码(第27也就是最后一行):


  1. server
  2. {
  3.   listen       80;
  4.   server_name att.xxx.com;
  5.   index index.html index.htm index.php default.html default.htm default.php;
  6.   root  /home/wwwroot/web;  include none.conf;
  7.   location ~ .*\.(php|php5)?$
  8.    {
  9.     fastcgi_pass  unix:/tmp/php-cgi.sock;
  10.     fastcgi_index index.php;
  11.     include fcgi.conf;
  12.    }
  13. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  14. {
  15. valid_referers none blocked *.xxx.info *.xxx.com;
  16. if ($invalid_referer) {
  17. rewrite ^/ http://xx.ooo.info/ad/daolian.jpg;
  18. #return 404;
  19. }
  20. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  21.    {
  22.     expires      30d;
  23.    }
  24. location ~ .*\.(js|css)?$
  25.    {
  26.     expires      12h;
  27.    }
  28.   access_log off;
  29. }
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2012-7-19 19:05:25 | 显示全部楼层



如果用上边的代码后,重启lnmp,

服务器上所有的网站都不能打开了。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2012-7-19 20:28:21 | 显示全部楼层

回复 3# 的帖子


#return 404;
下面少了一个}

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2012-7-19 20:44:36 | 显示全部楼层

额滴个神哪!终于搞定了。。。。

谢啦军哥。
发表于 2012-7-20 01:25:31 | 显示全部楼层

你还是编代码编译比较稳妥。我今天看到一些不错的安装nginx的文章。

评分

参与人数 1威望 -2 收起 理由
licess -2 广告/SPAM

查看全部评分

美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2012-12-9 11:07:09 | 显示全部楼层

Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-24 03:29 , Processed in 0.027521 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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