Installation and Initialization
Overview
BotManager-Cloudflare-Agent is designed to easily apply BotManager's detection capabilities using Cloudflare's Workers feature without modifying the Origin server.
BotManager is a solution that detects bots and macro users through various analysis techniques (header analysis, behavior analysis, foreign IP blocking, access statistics, etc.). This protects web services and safely manages data from threats of malicious users and automated bots.
What is Cloudflare Workers?
Cloudflare Workers is a serverless computing platform that can execute JavaScript, TypeScript, WebAssembly, etc. on Cloudflare's global network.
Key Features:
- Global Edge Network-Based Execution - Runs in over 300 cities worldwide, executing code closer to users to provide low latency and fast response speeds.
- Reduced Origin Server Load - Can process requests directly at the edge or perform tasks such as caching, authentication, and redirection, reducing Origin server load.
- Fast Deployment and Scalability - Can write code and deploy immediately without complex infrastructure setup, and automatically scales globally.
For more information about Cloudflare, refer to the official documentation:
Installation Methods
1. Create Worker and Set Configuration Values
- Navigate to Workers and Pages menu in Cloudflare management console.
- Click Create and create Workers as Hello world.
- Select the created Workers and Go to Settings.
- Add Route from Domain and Route.
- Zone: Select the domain to use from the list of domains registered in Cloudflare.
- Route: Enter the subdomain or domain where workers will run. Add
/*at the end to include sub-paths.
- Add Route from Domain and Route.
- Add the following environment variables to Variables and Secrets.
| Required | Type | Name | Default Value | Description |
|---|---|---|---|---|
| YES | Text | BM_DOMIN | {{domain}} | Domain registered by user in BotManager |
| YES | Text | BM_TENANT_ID | {{tenantId}} | Customer tenantId |
| No | Text | BM_PROTECTION_SERVER_URL | https://cdn-botmanager.stclab.com | Address to redirect when determined to be bot |
| No | Text | BM_SERVER_API_URL | /api/v1/macro | BotManager detection pathname |
| No | Text | BM_SERVER_URL | https://botmanager.stclab.com | BotManager detection server address |
| No | Text | BM_SERVER_TIMEOUT | 3000 | Timeout to BotManager detection server |
| No | Text | BM_BYPASS | false | Flag to disable BotManager operation |
| No | Text | BM_LOG_LEVEL | ERROR | Log level when integrating BotManager (DEBUG, INFO, WARN, ERROR) |
- Download the BotManager agent code file botmanager-cloudflare-agent.js from the path below.
- Click code edit at the top right of the dashboard to import the BotManager agent code file, modify the worker.js file code, and click Deploy.
worker.js Code:
import bmEvent from './botmanager-cloudflare-agent.js'
export default {
async fetch(request, env, ctx) {
return await bmEvent(request, env, ctx);
},
};
- Navigate to Deploy tab and check deployment status.
2. Installation Complete
BotManager-Cloudflare-Agent has been successfully installed. Verify that it operates according to the configured policies.