Block Abnormal Users on Cloudflare Worker Routes

Preface

After setting up rate limiting in the previous post, the worker's usage won't exceed the limit.
However, usage like this is definitely abnormal.
Let's see how to block these users.

Analysis

Compute & AI -> Workers & Pages -> Click on your worker -> Observability -> Traces

All requests can be seen here.

Obviously, these requests are all used to access a link like https://github.com/nap0o/*
So, we can block them specifically. 

Practice

Click on your domain -> Workers Routes -> Add route
Add route

Set
https://ghproxy.lvedong.eu.org/https:/github.com/nap0o/*
to None (no worker)


Set
https://ghproxy.lvedong.eu.org/*
to the ghproxy worker

=======

End


=======

Postscript

When you enter a URL like the following in the browser,
https://ghproxy-test.lvedong.eu.org/https://github.com/nap0o/icmp9.com/releases/download/icmp9/icmp9-docker-debian-arm64
CloudFlare will pre-process it into the following before entering its various components
https://ghproxy-test.lvedong.eu.org/https:/github.com/nap0o/icmp9.com/releases/download/icmp9/icmp9-docker-debian-arm64
Therefore, when setting up the domain's Route routing, we need to write it as
https://ghproxy.lvedong.eu.org/https:/github.com/nap0o/*

The same logic applies: you often see in worker.js the logic of restoring https:/ to https:// and then using the path as a URL to fetch.

=======

Related Recommendations

Comments