Installation and Initialization
This guide explains the installation and initialization process for NetFUNNEL Cloudflare agent.
Step 1: Worker Environment Setup
It is most important to set up the Cloudflare Worker environment by referring to Cloudflare's official documentation.
After checking the content about setting up a Worker project in Cloudflare's official documentation, set up the Worker environment according to the instructions.
Step 2: Get Client ID
- Go to NetFUNNEL console
- Click the profile icon in the top right
- Select
Integration Credentialsmenu - Copy
Client ID
Client ID Location
You can find it in the Integration Credentials menu after clicking the profile icon in the top right of the console screen.
Step 3: Create Worker
- Cloudflare console → Click [Workers and Pages] menu
- Click Workers [Create]
- Click [Hello world]
- Deploy to add
Step 4: Apply Agent to Worker
- Click [Edit code] in the top right
- Download
netfunnel-cloudflare-agent.jsfile from https://agent-lib.stclab.com/agents/cdn/cloudflare/netfunnel-cloudflare-agent-latest.js - Click [Explore] in the left tab of the code editor to show the file list
- Upload
netfunnel-cloudflare-agent.jsfile - Open
worker.jsfile and write the following code:
import handleEvent from './netfunnel-cloudflare-agent.js'
export default {
async fetch(request, env, ctx) {
return await handleEvent(request, env, ctx);
},
};
- Click the [Deploy] button in the top right to deploy the Worker
Step 5: Worker Configuration
Domain and Route Configuration
- Select the created Worker
- Click [Settings] menu
- Click [+ Add] in Domains and routes
- Click [Route]
- Select domain in [Zone]
- Enter the path where the Worker will run in [Route] (add
/*at the end so the Worker works on subpages as well) - Select [Open on failure (continue)]
- Click [Add route]
Environment Variable Configuration
Add environment variables to Variables and secrets by referring to the table below.
| Type | Name | Value |
|---|---|---|
| Text | CLIENT_ID | {{CLIENT_ID}} |
Check CLIENT_ID in the NetFUNNEL console.
After adding the variable, click [Deploy].
Step 6: Domain Configuration
- Go to Cloudflare DNS settings
- Set the domain configured in Step 5 as CNAME
- Must be set to Proxy type (orange cloud icon)
This configuration allows the Worker to run when requests come to that path.
Next Steps
- Initialization Settings: Environment variable and additional feature configuration
- Troubleshooting: Common issues and solutions