我们可以shell命令curl来模拟user_agent来访问一个网站
那通过
```
curl -A "123YisouSpider1.0" https://www.test.cn
curl -A "MJ12bot/v1.4.1" https://www.test.cn
```
这样我们可以查看网站的nginx日志
```
"111.1.70.2" | "111.1.70.2" | 26/Apr/2021:23:25:37 +0800 | "GET / HTTP/1.1" | 200 | "-" | "123YisouSpider1.0" | 101.91.24.25
"111.1.70.2" | "111.1.70.2" | 26/Apr/2021:23:26:56 +0800 | "GET / HTTP/1.1" | 403 | "-" | "MJ12bot/v1.4.1" | 101.91.24.25
```
我们可以在nginx配置文件中禁止这些user_agent
```
if ($user_agent ~ 'YisouSpider|MJ12bot/v1.4.2|YoudaoBot|Tomato')
{
return 403;
}
```