https://github.com/cf-jongsik/x-forwarded-blocker
https://github.com/cf-jongsik/x-forwarded-blocker
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/cf-jongsik/x-forwarded-blocker
- Owner: cf-jongsik
- Created: 2024-02-20T23:52:39.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-20T23:59:59.000Z (over 1 year ago)
- Last Synced: 2025-01-26T16:48:23.267Z (4 months ago)
- Language: TypeScript
- Size: 177 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
x-forwarded-for-blocker
using Cloudflare Workers to create a rule based on a ENV variable
the example code blocks every traffic contains IPs from IPTOBLOCK environment variable
modify the code to fit your needs
## Getting Started
### Prerequisites
1. create token from Cloudflare account with following access
Zone WAF : edit
Firewall Service : edit2. find your Zone ID from dashboard
### Installation
1. login to your Cloudflare profile
(the account must have an edit access from the zone you are modifying)2. Clone the repo
```sh
git clone https://github.com/cf-jongsik/x-forwarded-blocker.git
```
3. Install NPM packages
```sh
npm install
```
4. login
```sh
npm exec wrangler login
```
5. modify variable in wrangler.toml (csv style)
```sh
[vars]
IPTOBLOCK = x.x.x.x,y.y.y.y
```
7. deploy
```sh
npm exec wrangler deploy
```
8. add secret variable (API TOKEN + ZONE ID)
```sh
npm exec wrangler secret put CLOUDFLARE_API_TOKEN
```
```sh
npm exec wrangler secret put ZONEID
```