Introduction#
When an IP or domain name is blocked, you can use CloudFlare Workers for reverse proxying to access the target IP or domain.
Preparation#
- CloudFlare account
- Domain name
Getting Started#
-
Register and log in to your CloudFlare account.
-
Go to the Workers tab and click the "Create Service" button.
-
Enter a service name, leave the rest as default, and then click the "Create" button.
-
Enter the quick edit mode.
-
Copy and paste the following code (remember to replace the example domain with your own IP/domain), and then click the "Save and Deploy" button.
addEventListener( "fetch",event => { let url=new URL(event.request.url); url.hostname="abc.def.xyz"; // Replace with your own node IP/domain let request=new Request(url,event.request); event. respondWith( fetch(request) ) } )
-
Go to "Triggers" and click "Add Custom Domain".
-
Enter the subdomain you want to bind (Note: the top-level domain needs to be in your CloudFlare account).
-
Now you can access the custom domain.