File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 2424 - [Docker 参数示例](#docker-参数示例)
2525 - [Docker build \& Run](#docker-build--run)
2626 - [Docker compose](#docker-compose)
27+ - [防止爬虫抓取](#防止爬虫抓取)
2728 - [使用 Railway 部署](#使用-railway-部署)
2829 - [Railway 环境变量](#railway-环境变量)
2930 - [手动打包](#手动打包)
@@ -234,6 +235,21 @@ services:
234235` ` `
235236- ` OPENAI_API_BASE_URL` 可选,设置 `OPENAI_API_KEY` 时可用
236237- ` OPENAI_API_MODEL` 可选,设置 `OPENAI_API_KEY` 时可用
238+
239+ # ### 防止爬虫抓取
240+
241+ **nginx**
242+
243+ 将下面配置填入nginx配置文件中,可以参考 `docker-compose/nginx/nginx.conf` 文件中添加反爬虫的方法
244+
245+ ```
246+ # 防止爬虫抓取
247+ if ($http_user_agent ~* "360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot")
248+ {
249+ return 403;
250+ }
251+ ```
252+
237253### 使用 Railway 部署
238254
239255[](https://railway.app/new/template/yytmgc)
Original file line number Diff line number Diff line change @@ -3,6 +3,13 @@ server {
33 server_name localhost;
44 charset utf-8;
55 error_page 500 502 503 504 /50x .html;
6+
7+ # 防止爬虫抓取
8+ if ( $http_user_agent ~ * "360Spider|JikeSpider|Spider|spider|bot|Bot|2345Explorer|curl|wget|webZIP|qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot|NSPlayer|bingbot" )
9+ {
10+ return 403 ;
11+ }
12+
613 location / {
714 root /usr/share/nginx/html;
815 try_files $uri /index .html;
You can’t perform that action at this time.
0 commit comments