/cloudflare-originator

Cloudflare Origin Customizer, allowing to map Cloudflare CDN to Origin paths

Primary LanguageJavaScriptMIT LicenseMIT

CloudFlare Originator

Cloudflare Origin Customizer, allowing to map Cloudflare CDN to Origin paths

Install Cloudflare Originator with Cloudflare

Overview

This Cloudflare App attempts to replicate AWS CloudFront's convenient capability of mapping path of incoming requests to a different origin path.

Can be used as a standalone worker, see workers/worker.js for details.

Features

Cloudflare DNS

Adds DNS record used as your Cloudflare-backed CDN.

Cloudflare Workers

Adds Cloudflare Worker, which maps all incoming requests matching your Cloudflare CDN hostname to configured Origin path.

WARNING: When using S3 as Origin, make sure to have S3 URLs publicly reachable, or have appropriate bucket policy. See S3_as_Origin.md for example policy.

Setup

  • Fork and clone the repo.
  • Make desired changes.
  • Install the dependencies with yarn install then build the project with yarn build (or npm run build).
  • Next, navigate to Cloudflare App Creator and upload your project directory.

The App Creator will update automatically on file changes (Chrome only). Once you're done testing, press Create App to submit your app for moderation. Refer to our Terms of Use for more information.

Usage

  • yarn start (or npm start) Sets up your dev environment and runs Webpack in watch mode.
  • yarn build (or npm run build) Lints your project and compiles your JavaScript and CSS once for release.

Other Interesting Scripts

  • dev:setup Add other initialization scripts to your development pipeline here.

The project uses yarn-run-all which makes it easy to run tasks in series or parallel using yarn or npm.

Details

install.json

This is where all the installer options are added for the app.

DNS field is used to to configure Cloudflare DNS Records. If you don't want to configure DNS, just delete this field.

src/index.js

This is where the magic happens. Your app starts here.

src/styles.css

Write your app styles here.

workers/worker.js

This file is used to add a Cloudflare Worker to the app. Each app may contain one worker. If you don't want to use workers, just delete this file along with the workers configuration in install.json.

media/**

Contains icons, tile images, and screenshots used in your Cloudflare Apps page.

Download media-templates.sketch

webpack.config.js

Simple Webpack 4 config using Babel and CSS Loader. Please refrain from modifying the config to minify your built code.

Troubleshooting

The Cloudflare developer documentation for examples and API usage.

Authors

  • Anastas Dancha (aka @anapsix) - original implementation
  • Nicole Corbin (aka @ncorbin) - logo artwork