nerbiz/crawl-shield
Composer 安装命令:
composer require nerbiz/crawl-shield
包简介
Prevent search engine crawlers from indexing your Laravel dev/test sites
README 文档
README
Prevent search engine crawlers from accessing your online test environments, by using a very simple password mechanism.
⚠️ This is not in any way intended for security!
It will prevent crawlers from indexing your temporary testing environment and to a certain degree it also prevents unwanted visits, but don't use this for application security.
The concept
A ?pass=... requirement is added to your routes using middleware. This is easy to use and remember by you, but unknown to search engines.
The goal is to block all crawlers from indexing any test-environment content, in a way that always works. The mechanism is disabled on production by default.
Installation
Install this package using Composer:
composer require nerbiz/crawl-shield
Usage
Configuration
If needed, you can add settings to your .env file.
The default values result in https://example.com/?pass=abc123, you change that parameter and password with these:
CRAWL_SHIELD_PARAMETER(default 'pass')CRAWL_SHIELD_PASSWORD(default 'abc123')
You can also disable the mechanism, or make it active in production:
CRAWL_SHIELD_ENABLED(default true)CRAWL_SHIELD_ENABLED_IN_PRODUCTION(default false)
If you wish to publish the config file to your own config/ directory, use this command:
php artisan vendor:publish --tag=crawl-shield
Add middleware
You have several options to apply the middleware in App\Http\Kernel, depending on how you want to shield your routes.
// Option 1: Shield all routes protected $middleware = [ // ... \Nerbiz\CrawlShield\Middleware\CrawlShieldMiddleware::class, ]; // Option 2: Shield only specific route group(s) protected $middlewareGroups = [ 'web' => [ // ... \Nerbiz\CrawlShield\Middleware\CrawlShieldMiddleware::class, ], // ... ]; // Option 3: Custom usage in your routes/ directory protected $middlewareAliases = [ // ... 'crawl-shield' => \Nerbiz\CrawlShield\Middleware\CrawlShieldMiddleware::class, ];
Result
If you visit https://your-app, it will return a 403 status, if it's in a development environment. You can then bypass this 403 by visiting https://your-app/?pass=abc123. This is remembered in the session, so you don't need the password in every route afterwards.
nerbiz/crawl-shield 适用场景与选型建议
nerbiz/crawl-shield 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 24 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 01 月 15 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 nerbiz/crawl-shield 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nerbiz/crawl-shield 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 24
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-01-15