Code Monkey home page Code Monkey logo

cloudflare-acl-worker's Introduction

Cloudflare ACL Worker Proxy

Create a file access.json in the root directory of your public html folder where your site is served.

{
  "host": "example.com",
  "blacklist": ["/access.json"],
  "rules": [
    ...
  ]
}

Where rules are executed in order on each request.

Make sure blacklist at least contains your access.json file, otherwise it will be exposed to the public through any allow: true rules.

Environment Variables

WORKER=worker-name-on-cloudflare
CLOUDFLARE_AUTH_KEY=auth-key-on-cloudflare
CLOUDFLARE_AUTH_EMAIL=auth-email-on-cloudflare
CLOUDFLARE_ACCOUNT_ID=account-id-on-cloudflare
CLOUDFLARE_ZONE_ID=zone-id-on-cloudflare
SITE=url-and-path-to-default-site

access.json is to be found at the root of the site given in SITE

Deployment

yarn sls deploy

Rule Matching

Source IP Address

{
  "remoteAddress": ["ip_address"],
  ...
}

Query Parameters

{
  "query": {
    "name": "value",
    ...
  },
  ...
}

Cookies

{
  "cookies": {
    "name": "value",
    ...
  },
  ...
}

Path Prefixes

{
  "path": "/path/to/files",
  ...
}

Rule Targets

Redirect

To redirect to the pathname and hash of the matched document:

{
  "redirect": ":pathname"
}

To redirect to a relative or absolute url:

{
  "redirect": "http://example.com"
}

Proxy

To proxy a HTTP site:

{
  "serve": "https://example.com/path/to/files"
}

Default site

To pass through to the default site where the access.json is found:

{
  "allow": true
}

cloudflare-acl-worker's People

Contributors

timoshisa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.