KnowledgebaseTutorialWeb Development

Tutorial: Use Cloudflare Cron Triggers for Invision Community (IPS) Tasks Method

Invision Community (IPS) supports multiple task execution methods for its self-hosted “Classic” package. Options include on-premises cron, traffic‑based tasks, and external web services. Use of an on premises, local cron is recommended because it generally the most reliable and secure method. However, some hosting services, restrict cron jobs executions to interval of more than the recommended one per minute. When using Cloudflare as your CDN and security layer, you can take advantage of Cloudflare Workers / Cron Triggers to run IPS background tasks every minute — even on shared hosting.

This tutorial walks you through the complete setup.

Step 1: Create a Cloudflare Worker and Cron Trigger

1. Open Cloudflare and select your domain

From your Cloudflare dashboard:

  • Choose the domain where your IPS community is hosted.

2. Navigate to Workers & Pages

In the left navigation menu:

Build → Compute → Workers & Pages

3. Create a new Worker

Click Create application.

On the next screen, choose: Start with Hello World!

Cloudflare will display:

  • A field for the Worker name
  • A preview of the default JavaScript code

Click Deploy to create the Worker.

4. Edit the Worker code

After deployment, click: </> Edit code

Replace the default Worker code with the following:

export default {
  async scheduled(event, env, ctx) {
    ctx.waitUntil(runICCron());
  }
};

async function runICCron() {
  const response = await fetch("https://yourdomain.com/applications/core/interface/task/web.php?key={your-key}", {
    method: "GET",
    headers: {
      "User-Agent": "My-Cloudflare-Cron/1.0"
    }
  });

  console.log("IC Cron executed:", response.status);
}

5. Customize the Worker

Replace:

  • https://yourdomain.com/applications/core/interface/task/web.php?key={your-key} with the exact URL IPS provides in the ACP (see Step 2).
  • My-Cloudflare-Cron/1.0 with any custom User-Agent string you prefer.

You may delete the default fetch() handler Cloudflare includes. It is not required for scheduled Workers.

6. Deploy the updated Worker

Click Deploy in the top‑right corner.

Then click the Worker name to return to the Worker dashboard.

7. Add a Cron Trigger

In the Worker dashboard:

  • Click Settings. You may have to scroll right to see the Settings menu item.
  • Scroll down to Trigger events
  • Under Cron Triggers, click + Add

Choose:

  • Minutes
  • Enter a one (1) in the Execute Worker Every section (IPS recommends running tasks every minute)

Click Add, then Save.

Your Cloudflare Worker will now execute every minute.

Step 2: Configure IPS to “Use Web Service” Task Method

1. Log into your IPS Admin Control Panel

Navigate to:

ACP → System → Settings → Advanced Configuration

2. Select “Use web service”

Under Tasks → Task Method, choose: Use web service

IPS will display a message similar to:

You should set the service to call the following URL every minute: https://example.com/applications/core/interface/task/web.php?key={your-unique-key}

This is the URL your Cloudflare Worker must call.

3. Save your settings

Click Save.

Your IPS installation is now configured to accept cron calls from Cloudflare.

Step 3: Secure Your IPS Task Endpoint (Recommended)

Invision Community provides two task runner interfaces: task.php for local cron (CLI) and web.php for external web services (HTTP). Although both ultimately execute queued tasks, they serve different purposes. task.php is only used when the Task Method is set to “Use cron (Recommended)” and cannot be executed via HTTP. web.php is used when the Task Method is set to “Use web service” and must be publicly accessible to external cron providers such as EasyCron, cron-job.org, or Cloudflare Workers. Because web.php is reachable over the internet, it must be protected using IP whitelisting or firewall rules. task.php does not require protection because it already blocks HTTP access and is only executed locally.

Because Cloudflare Workers will be calling your IPS task URL, you should restrict access to Cloudflare’s IP ranges.

Add the following to your .htaccess inside your IPS installation directory:

<Files "web.php">
    <RequireAny>
        Require ip 173.245.48.0/20
        Require ip 103.21.244.0/22
        Require ip 103.22.200.0/22
        Require ip 103.31.4.0/22
        Require ip 141.101.64.0/18
        Require ip 108.162.192.0/18
        Require ip 190.93.240.0/20
        Require ip 188.114.96.0/20
        Require ip 197.234.240.0/22
        Require ip 198.41.128.0/17
    </RequireAny>
</Files>

This ensures that only Cloudflare can access your task runner.

Step 4: Verify Cron Execution

Cloudflare provides logs for scheduled Workers:

  • Open your Worker
  • Click Logs
  • Look for entries such as:
IC Cron executed: 200

A status of 200 or 204 indicates successful execution.

If you see 403, your .htaccess rules need adjustment.

Conclusion

You have now fully configured Invision Community to use Cloudflare Workers Cron Triggers as its task execution method. Cloudflare Cron Triggers are efficient, cost-effective, and included in both free and paid tiers, making them a powerful tool for automating tasks at the edge.

Source
Cloudflare — Cron TriggersCloudflare — IP Ranges

EDK-Tech

I’m an emerging IT and electronics technician focused on building strong foundational skills in networking, connectivity, and hands‑on system troubleshooting. Alongside my IT and electronics work, I have experience in web development and WordPress engineering, including custom plugin development, shortcode systems, UI/UX improvements, and modular, scalable code design. I enjoy creating tools that solve real problems, improve workflows, and enhance the user experience.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *


Math Captcha
33 − 29 =


Check Also
Close
Back to top button