Workers-Proxy is a lightweight Javascript application that retrieves resource as a client from other servers.
Deploying on Cloudflare Workers, which is an influential platform for building serverless applications, you could build customized reverse proxy without purchasing computing engines and configuring web servers such as Nginx.
Moreover, crucial performance, such as latency and availability, will be optimized, since your application will be distributed through Cloudflare's global network of data centers in more than 90 countries.
By configuring Geolocation and IP address filters, you might directly suspend your reverse proxy service in specific countries or regions according to their regulations. Taking advantage of the mobile redirector, you could distribute various webpages based on users' devices.
Reverse-Proxy Project (This demo may not available in specific regions.)
Generate a new project.
wrangler generate my-workers-proxy https://github.com/Siujoeng-Lau/Workers-Proxy
wrangler.toml
file to prepare your project for deployment.wrangler config
wrangler build
wrangler publish
Navigate to Cloudflare Workers, register or sign in your Cloudflare account, and set custom subdomain for workers, and create a new Worker.
Customize 'index.js', paste the code into Cloudflare online editor to replace the default one.
Change name of your Worker, save and deploy it, and check whether its performance fulfills your demand.
Check whether your domain is currently under Cloudflare's protection.
Navigate to the dashboard of your domain, select 'Workers' page, and click on 'Add Route'.
Type https://<domain-name>/*
in Route
and select the Worker you created previously.
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'.
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 expectations.
// Website you intended to retrieve for users.
const upstream = 'www.google.com'
// 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']
// Replace texts.
const replace_dict = {
'$upstream': '$custom_domain',
'//google.com': ''
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型