RavenLame
CDCloudflare Developers
•Created by RavenLame on 10/3/2024 in #pages-help
Hosting proxy pac on workers
export default {
async fetch(request) {
const pac =
function FindProxyForURL(url, host) {
// No proxy for private (RFC 1918) IP addresses (intranet sites)
if (
isInNet(dnsResolve(host), "10.0.0.0", "255.0.0.0") ||
isInNet(dnsResolve(host), "172.16.0.0", "255.240.0.0") ||
isInNet(dnsResolve(host), "192.168.0.0", "255.255.0.0")
) {
return "DIRECT";
}
// No proxy for localhost
if (isInNet(dnsResolve(host), "127.0.0.0", "255.0.0.0")) {
return "DIRECT";
}
// Proxy all
return "HTTPS 3ele0ss56t.proxy.cloudflare-gateway.com:443";
}
;
return new Response(pac, {
headers: {
"content-type": "text/plain;charset=UTF-8",
},
});
},
};4 replies
CDCloudflare Developers
•Created by RavenLame on 10/3/2024 in #pages-help
Hosting proxy pac on workers
This is the right code below, if it can help someone else :
4 replies