location 内的 if 判断后不能直接配置root 命令
if ($remote_addr !~* 1.1.1.1){
;
}
return 403;
}
这样写if 判断看里面访问静态页面是没有效果的 这个时候如果想要满足基于特定的条件,比如客户端ip 返回不同的内容怎么处理呢? 1、if 判断后面试用重写rewrite 到不同的页面
if ($remote_addr ~* 1.1.1.1){
rewrite ^(.*)$ http://abc.com;
}
return 403;
}
2、if 反向判断 root 命令只是不能再if判断后执行,那就放在外层即可
if ($remote_addr !~* 1.1.1.1){
return 403;
}
root /nginx/text/;
}