`

nginx: [emerg] unknown directive

阅读更多

服务器遭到一个agent包含java/1.6.0的频繁攻击,本打算按照如下的方式配置nginx来屏蔽请求

 location /{

       if($http_user_agent ~* "java/1.6.0"){

           rewrite ^(.*)$ http://img.mp.itc.cn/upload/20160716/6362d52b6ade45cdb6e354fd9de64d4a_th.jpg redirect;

       }

    }

nginx重启的时候出现如下异常:

nginx: [emerg] unknown directive "if($http_user_agent" in /usr/local/nginx/conf/nginx.conf:86

原因是:

    if 和 ( 缺一个空格 ,如果没有空格他把if($http_user_agent当成一个指令去执行,很显然这样是错误的。

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics