Client --> BlockedServer: GET xxx note left of Client: I cannot GET! Client -> CF Worker: GET Blocked Server for me! note right of CF Worker: I can GET! CF Worker -> BlockedServer: GET xxx BlockedServer -> CF Worker: Responce xxx CF Worker -> Client: Responce xxx
if (blocked_region.includes(region)) { response = new Response('Access denied: WorkersProxy is not available in your region yet.', { status: 403 }); } elseif (blocked_ip_address.includes(ip_address)) { response = new Response('Access denied: Your IP address is blocked by WorkersProxy.', { status: 403 }); } else { let method = request.method; let request_headers = request.headers; let new_request_headers = new Headers(request_headers);
let original_response_clone = original_response.clone(); let original_text = null; let response_headers = original_response.headers; let new_response_headers = new Headers(response_headers); let status = original_response.status;
let re = newRegExp(i, 'g') text = text.replace(re, j); } return text; }
asyncfunctiondevice_status(user_agent_info) { var agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; var flag = true; for (var v = 0; v < agents.length; v++) { if (user_agent_info.indexOf(agents[v]) > 0) { flag = false; break; } } return flag; }
然后我们把它复制到左边的代码块中。这里面有几个我们需要修改的地方:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// 你要镜像的网站. const upstream = 'www.google.com'
// 镜像网站的目录,比如你想镜像某个网站的二级目录则填写二级目录的目录名,镜像 google 用不到,默认即可. const upstream_path = '/'