Skip to main content
Version: 4.6.1-saas

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

  1. Go to NetFUNNEL console
  2. Click the profile icon in the top right
  3. Select Integration Credentials menu
  4. 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

  1. Cloudflare console → Click [Workers and Pages] menu
  2. Click Workers [Create]
  3. Click [Hello world]
  4. Deploy to add

Step 4: Apply Agent to Worker

  1. Click [Edit code] in the top right
  2. Download netfunnel-cloudflare-agent.js file from https://agent-lib.stclab.com/agents/cdn/cloudflare/netfunnel-cloudflare-agent-latest.js
  3. Click [Explore] in the left tab of the code editor to show the file list
  4. Upload netfunnel-cloudflare-agent.js file
  5. Open worker.js file 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);
},
};
  1. Click the [Deploy] button in the top right to deploy the Worker

Step 5: Worker Configuration

Domain and Route Configuration

  1. Select the created Worker
  2. Click [Settings] menu
  3. Click [+ Add] in Domains and routes
  4. Click [Route]
  5. Select domain in [Zone]
  6. Enter the path where the Worker will run in [Route] (add /* at the end so the Worker works on subpages as well)
  7. Select [Open on failure (continue)]
  8. Click [Add route]

Environment Variable Configuration

Add environment variables to Variables and secrets by referring to the table below.

TypeNameValue
TextCLIENT_ID{{CLIENT_ID}}

Check CLIENT_ID in the NetFUNNEL console.

After adding the variable, click [Deploy].


Step 6: Domain Configuration

  1. Go to Cloudflare DNS settings
  2. Set the domain configured in Step 5 as CNAME
  3. Must be set to Proxy type (orange cloud icon)

This configuration allows the Worker to run when requests come to that path.


Next Steps