Coder Social home page Coder Social logo

3333's Introduction

Workers-Proxy

LICENSE GitHub closed issues GitHub stars

Languages: English, 简体中文.

Introduction

Workers-Proxy is a lightweight Javascript Reverse Proxy based on Cloudflare Workers.

Users could deploy the reverse proxy on Cloudflare's global network without setting up virtual private servers and configuring Nginx or Apache.

Features

  • Build mirror websites
  • Improve loading speed with Cloudflare's global network
  • Increase security (Hide IP addresses of websites)
  • Block specific areas or IP addresses
  • Redirect mobile users to different web pages

Demo

Reverse-Proxy Project (This demo may not be available in specific regions.)

UCLA

Python Documentation

Getting Started

Build and Deploy

Deploy with Wrangler

  1. Installing Wrangler.

  2. Generate a new project.

wrangler generate my-workers-proxy https://github.com/Siujoeng-Lau/Workers-Proxy
  1. Configure your project's wrangler.toml file to prepare your project for deployment.
wrangler config
  1. Build and deploy on Cloudflare Workers.
wrangler build
wrangler publish

Deploy manually

  1. Navigate to Cloudflare Workers, register or sign in your Cloudflare account, and set custom subdomain for workers, and create a new Worker.

  2. Customize 'src/index.js', paste the code into Cloudflare online editor to replace the default one.

  3. Change name of your Worker, save and deploy it, and check whether its performance fulfills your demand.

Bind to Custom Domain

  1. Check whether your domain is currently under Cloudflare's protection.

  2. Navigate to the dashboard of your domain, select 'Workers' page, and click on 'Add Route'.

  3. Type https://<domain_name>/* in Route and select the Worker you created previously.

  4. Add a CNAME DNS record for your custom domain. Concretely, enter the subdomain (or '@' for root) in the 'Name' field, enter the second level domain of your workers in the 'Target' field, and set 'Proxy status' to 'Proxied'.

Customize index.js

Basically, there are a few constants on the top of the 'index.js' file.

To customize your own Workers-Proxy Service, you should edit these constants according to your demands.

// Website you intended to retrieve for users.
const upstream = 'www.google.com'

// Custom pathname for the upstream website.
const upstream_path = '/'

// Website you intended to retrieve for users using mobile devices.
const upstream_mobile = 'www.google.com'

// Countries and regions where you wish to suspend your service.
const blocked_region = ['CN', 'KP', 'SY', 'PK', 'CU']

// IP addresses which you wish to block from using your service.
const blocked_ip_address = ['0.0.0.0', '127.0.0.1']

// Whether to use HTTPS protocol for upstream address.
const https = true

// Whether to disable cache.
const disable_cache = false

// Replace texts.
const replace_dict = {
    '$upstream': '$custom_domain',
    '//google.com': ''
}

Example Configurations

Websites with Multiple Domains

If the website uses another domain name to serve static resources, users could deploy multiple Workers-Proxy and configure text replacement.

  1. www.google.com serve static resources on www.gstatic.com
  2. Deploy Workers-Proxy A to proxy www.gstatic.com
  3. Deploy Workers-Proxy B to proxy www.google.com
  4. Configure text replacement for Workers-Proxy B:
const replace_dict = {
    '$upstream': '$custom_domain',
    'www.gstatic.com': '<Domain name of Workers-Proxy A>'
}

3333's People

Contributors

xiaoyang-sde avatar jimmytinsley avatar azhuge233 avatar liberty-song avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.