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当成一个指令去执行,很显然这样是错误的。
相关推荐
nginxs 2020-11-14
Guanjs0 2020-11-13
小木兮子 2020-11-11
yserver 2020-11-11
ssihc0 2020-11-11
windle 2020-11-10
HanksWang 2020-11-10
liuchen0 2020-11-10
Freshairx 2020-11-10
ccschan 2020-11-10
liwf 2020-11-10
Guanjs0 2020-11-09
AderStep 2020-11-09
zrtlin 2020-11-09
mqfcu 2020-11-10
windle 2020-10-29