We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bfd6f83 commit 677a2a1Copy full SHA for 677a2a1
README.md
@@ -64,6 +64,7 @@ Nginx版本:`1.11.5`
64
- [强制将http重定向到https](#强制将http重定向到https)
65
- [两个虚拟主机](#两个虚拟主机)
66
- [虚拟主机标准配置](#虚拟主机标准配置)
67
+ - [爬虫过滤](#爬虫过滤)
68
- [防盗链](#防盗链)
69
- [虚拟目录配置](#虚拟目录配置)
70
- [防盗图配置](#防盗图配置)
@@ -1233,6 +1234,22 @@ http {
1233
1234
}
1235
```
1236
1237
+### 爬虫过滤
1238
+
1239
+根据 `User-Agent` 过滤请求,通过一个简单的正则表达式,就可以过滤不符合要求的爬虫请求(初级爬虫)。
1240
1241
+> `~*` 表示不区分大小写的正则匹配
1242
1243
+```nginx
1244
+location / {
1245
+ if ($http_user_agent ~* "python|curl|java|wget|httpclient|okhttp") {
1246
+ return 503;
1247
+ }
1248
+ # 正常处理
1249
+ # ...
1250
+}
1251
+```
1252
1253
### 防盗链
1254
1255
```nginx
0 commit comments