File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 4848 - [Docker 参数示例](#docker-参数示例)
4949 - [Docker build \& Run](#docker-build--run)
5050 - [Docker compose](#docker-compose)
51+ - [防止爬虫抓取](#防止爬虫抓取)
5152 - [使用 Railway 部署](#使用-railway-部署)
5253 - [Railway 环境变量](#railway-环境变量)
5354 - [手动打包](#手动打包)
@@ -311,6 +312,20 @@ volumes:
311312` ` `
312313- ` OPENAI_API_BASE_URL` 可选,设置 `OPENAI_API_KEY` 时可用
313314- ` OPENAI_API_MODEL` 可选,设置 `OPENAI_API_KEY` 时可用
315+
316+ # ### 防止爬虫抓取
317+
318+ **nginx**
319+
320+ 将下面配置填入nginx配置文件中,可以参考 `docker-compose/nginx/nginx.conf` 文件中添加反爬虫的方法
321+
322+ ```
323+ # 防止爬虫抓取
324+ 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"){
325+ return 403;
326+ }
327+ ```
328+
314329### 使用 Railway 部署
315330
316331[](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+ return 403 ;
10+ }
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