banner
年糕

年糕日记

此站为备份站点,最新文章请访问 oior.net
telegram
email

CloudFlare Workers Reverse Proxy Tutorial

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#

  1. Register and log in to your CloudFlare account.

  2. Go to the Workers tab and click the "Create Service" button. Create Service

  3. Enter a service name, leave the rest as default, and then click the "Create" button. Create Service

  4. Enter the quick edit mode. Quick Edit

  5. 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. Code

    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)
         )
      }
    )
    
  6. Go to "Triggers" and click "Add Custom Domain". Add Custom Domain

  7. Enter the subdomain you want to bind (Note: the top-level domain needs to be in your CloudFlare account).

  8. Now you can access the custom domain.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.