Sign inSign up

senthora/cfmock

By senthora

•Updated 5 months ago

Local Cloudflare IP API simulator for testing nginx and firewall trust rules

Image
0

269

senthora/cfmock repository overview

⁠CFMock

CFMock is a lightweight Cloudflare IP API emulator for local development and integration testing.

It serves Cloudflare-compatible IP range responses over HTTP using nginx and a small Go control utility.

⁠Quick Start

Run CFMock using Docker Compose:

services:
  cfmock:
    image: senthora/cfmock:latest
    ports:
      - "80:80"
    tmpfs:
      - /usr/share/nginx/html
    environment:
      ETAG: a8e453d9d129a3769407127936edfdb0
      IPV4_CIDRS: 199.27.128.0/21
      IPV6_CIDRS: 2400:cb00::/32
    restart: unless-stopped

Start container:

docker compose up -d

Verify response:

curl http://localhost/client/v4/ips

⁠Endpoints

EndpointDescription
/client/v4/ipsMock Cloudflare IP API
/healthContainer health endpoint

All other endpoints return 404.

⁠Environment Variables

VariableDescription
ETAGResponse ETag
IPV4_CIDRSComma-separated IPv4 CIDRs
IPV6_CIDRSComma-separated IPv6 CIDRs

Important

When running in a container, `cfmock set` is executed automatically on startup. This allows response state to be initialized directly from environment variables.

⁠Example Response

{
  "errors": null,
  "messages": null,
  "success": false,
  "result": {
    "etag": "a8e453d9d129a3769407127936edfdb0",
    "ipv4_cidrs": [
      "199.27.128.0/21"
    ],
    "ipv6_cidrs": [
      "2400:cb00::/32"
    ]
  }
}

For full documentation read the CFMock README⁠.

Tag summary

Content type

Image

Digest

sha256:d2dc2d07a…

Size

6.4 MB

Last updated

5 months ago

docker pull senthora/cfmock