leexee 发表于 2012-7-19 18:30:06

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

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

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

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


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

server
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
                         {
                                 valid_referers none blocked *.xxx.info *.xxx.com;
                                 if ($invalid_referer) {
                                 rewrite ^/ http://xx.ooo.info/ad/daolian.jpg;
                                 #return 404;
                                 }
{
listen       80;
server_name att.xxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/web;include none.conf;
location ~ .*\.(php|php5)?$
   {
    fastcgi_passunix:/tmp/php-cgi.sock;
    fastcgi_index index.php;
    include fcgi.conf;
   }

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
   {
    expires      30d;
   }location ~ .*\.(js|css)?$
   {
    expires      12h;
   }access_log off;
}

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

2012/07/19 18:15:15 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 编辑 ]

licess 发表于 2012-7-19 18:47:00

server
{
listen       80;
server_name att.xxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/web;include none.conf;
location ~ .*\.(php|php5)?$
   {
    fastcgi_passunix:/tmp/php-cgi.sock;
    fastcgi_index index.php;
    include fcgi.conf;
   }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
valid_referers none blocked *.xxx.info *.xxx.com;
if ($invalid_referer) {
rewrite ^/ http://xx.ooo.info/ad/daolian.jpg;
#return 404;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
   {
    expires      30d;
   }
location ~ .*\.(js|css)?$
   {
    expires      12h;
   }
access_log off;
}

leexee 发表于 2012-7-19 18:58:00

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

2012/07/19 18:49:10 3356#0: unexpected end of file, expecting "}" in /usr/local/nginx/conf/vhost/att.xxx.com.conf:27

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


server
{
listen       80;
server_name att.xxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root/home/wwwroot/web;include none.conf;
location ~ .*\.(php|php5)?$
   {
    fastcgi_passunix:/tmp/php-cgi.sock;
    fastcgi_index index.php;
    include fcgi.conf;
   }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
valid_referers none blocked *.xxx.info *.xxx.com;
if ($invalid_referer) {
rewrite ^/ http://xx.ooo.info/ad/daolian.jpg;
#return 404;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
   {
    expires      30d;
   }
location ~ .*\.(js|css)?$
   {
    expires      12h;
   }
access_log off;
}

leexee 发表于 2012-7-19 19:05:25

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

服务器上所有的网站都不能打开了。

licess 发表于 2012-7-19 20:28:21

回复 3# 的帖子

#return 404;
下面少了一个}

leexee 发表于 2012-7-19 20:44:36

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

谢啦军哥。

cnncnn 发表于 2012-7-20 01:25:31

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

hoteri 发表于 2012-12-9 11:07:09

页: [1]
查看完整版本: 求军哥看看我的防盗链代码到底错在哪里了。