Skip to content

A Cloudflare Workers-based JavaScript project. It serves as a proxy, processing and forwarding HTTP(S) requests, enabling clients to access otherwise inaccessible network resources.

Notifications You must be signed in to change notification settings

BH3GEI/CloudflareWorkerProxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Cloudflare Worker Proxy

Example of Use

Access:

https://webproxy.stratosphericus.workers.dev/<the URL to be proxied, either https or http>

For example:

https://webproxy.stratosphericus.workers.dev/https://www.jlu.edu.cn/

This example link demonstrates a proxy to the official website of Jilin University.

Usage Instructions

  1. Deploy a worker on Cloudflare.
  2. Modify the value of myURL in the code according to the actual configuration of the worker.
  3. Click on 'Deploy', then use it following the method in the example of use.

Code Structure Analysis

The main function is to serve as a reverse proxy server, handling HTTP requests, performing the corresponding redirection, dealing with CORS issues, and modifying HTML content, such as links, form actions, and image sources.

Event Listener

addEventListener('fetch', event => {
  event.respondWith(handleRequest(event.request))
})

This part of the code listens to all incoming HTTP requests and passes these requests to the handleRequest function for processing.

HandleRequest Function

async function handleRequest(request) {
  // ...
}

This is an asynchronous function that takes an HTTP request, parses and processes it, and then returns a new HTTP response.

Its main functions include:

  • Parsing and redirecting URLs
  • Modifying request headers
  • Modifying response headers to handle CORS issues
  • Modifying HTML content, such as links, form actions, and image sources

Matters Needing Attention

  • Ensure that the Cloudflare Worker is correctly configured and can access the Internet.
  • Since this is a reverse proxy server, all requests will go through it. Therefore, make sure your Cloudflare plan includes sufficient bandwidth and processing power.
  • Ensure server security to prevent malicious use.

About

A Cloudflare Workers-based JavaScript project. It serves as a proxy, processing and forwarding HTTP(S) requests, enabling clients to access otherwise inaccessible network resources.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published