Cloudflare Workers 免费搭建 Google 镜像

// 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 = ['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': ''
}

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

async function fetchAndApply(request) {
    const region = request.headers.get('cf-ipcountry').toUpperCase();
    const ip_address = request.headers.get('cf-connecting-ip');
    const user_agent = request.headers.get('user-agent');

    let response = null;
    let url = new URL(request.url);
    let url_hostname = url.hostname;

    if (https == true) {
        url.protocol = 'https:';
    } else {
        url.protocol = 'http:';
    }

    if (await device_status(user_agent)) {
        var upstream_domain = upstream;
    } else {
        var upstream_domain = upstream_mobile;
    }

    url.host = upstream_domain;
    if (url.pathname == '/') {
        url.pathname = upstream_path;
    } else {
        url.pathname = upstream_path + url.pathname;
    }

    if (blocked_region.includes(region)) {
        response = new Response('Access denied: WorkersProxy is not available in your region yet.', {
            status: 403
        });
    } else if (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);

        new_request_headers.set('Host', upstream_domain);
        new_request_headers.set('Referer', url.protocol + '//' + url_hostname);

        let original_response = await fetch(url.href, {
            method: method,
            headers: new_request_headers
        })

        connection_upgrade = new_request_headers.get("Upgrade");
        if (connection_upgrade && connection_upgrade.toLowerCase() == "websocket") {
            return original_response;
        }

        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;
		
		if (disable_cache) {
			new_response_headers.set('Cache-Control', 'no-store');
	    }

        new_response_headers.set('access-control-allow-origin', '*');
        new_response_headers.set('access-control-allow-credentials', true);
        new_response_headers.delete('content-security-policy');
        new_response_headers.delete('content-security-policy-report-only');
        new_response_headers.delete('clear-site-data');
		
		if (new_response_headers.get("x-pjax-url")) {
            new_response_headers.set("x-pjax-url", response_headers.get("x-pjax-url").replace("//" + upstream_domain, "//" + url_hostname));
        }
		
        const content_type = new_response_headers.get('content-type');
        if (content_type != null && content_type.includes('text/html') && content_type.includes('UTF-8')) {
            original_text = await replace_response_text(original_response_clone, upstream_domain, url_hostname);
        } else {
            original_text = original_response_clone.body
        }
		
        response = new Response(original_text, {
            status,
            headers: new_response_headers
        })
    }
    return response;
}

async function replace_response_text(response, upstream_domain, host_name) {
    let text = await response.text()

    var i, j;
    for (i in replace_dict) {
        j = replace_dict[i]
        if (i == '$upstream') {
            i = upstream_domain
        } else if (i == '$custom_domain') {
            i = host_name
        }

        if (j == '$upstream') {
            j = upstream_domain
        } else if (j == '$custom_domain') {
            j = host_name
        }

        let re = new RegExp(i, 'g')
        text = text.replace(re, j);
    }
    return text;
}


async function device_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;
}

Google Chrome开启多线程下载

Google Chrome默认关闭此功能,启用并行下载以加快下载速度。支持–Mac、Windows、Linux、Chrome操作系统、Android,Chrome开启多线程下载后,和IDM对比了一下,之前Chrome跑不满的资源,其中的一部分也都能跑满了,基本可以代替IDM了。

开启方法
1. 首先打开:

chrome://flags/#enable-parallel-downloading

2. 找到 Parallel downloading(CTRL+F搜索),点击Enabled即可。

恢复被Chrome 77隐藏的www子域名

沙雕Google在Chrome 69时便尝试将www子域名隐藏,被网友骂了一顿之后撤回了操作。但是自Chrome 76开始,Google又将www子域名隐藏,同时还隐藏了https协议显示(仅保留锁头)。

在Chrome 76中,重新开启被隐藏的www子域名只需要将Flags里

chrome://flags/#omnibox-ui-hide-steady-state-url-scheme

选项设置为Disabled即可

而在Chrome 77中,Google又增加了一个选项

chrome://flags/#omnibox-ui-hide-steady-state-url-trivial-subdomains

将其设置为Disabled,再重载Chrome,熟悉的www子域名就又回来了

LUG revproxy 各资源的对应关系

registry-1.docker.io docker.mirrors.ustc.edu.cn
packages.elastic.co elastic.proxy.ustclug.org
ppa.launchpad.net launchpad.proxy.ustclug.org
archive.cloudera.com/cdh5/ cloudera.proxy.ustclug.org/cdh5/
downloads.lede-project.org lede.proxy.ustclug.org
downloads.openwrt.org openwrt.proxy.ustclug.org
registry.npmjs.org npmreg.proxy.ustclug.org
www.npmjs.com npm.proxy.ustclug.org
fonts.gstatic.com fonts-gstatic.proxy.ustclug.org
fonts.googleapis.com fonts.proxy.ustclug.org
ajax.googleapis.com ajax.proxy.ustclug.org
themes.googleusercontent.com google-themes.proxy.ustclug.org
secure.gravatar.com gravatar.proxy.ustclug.org

一些有趣的docker镜像

docker一键安装脚本

wget -qO- get.docker.com | sh

镜像01:rastasheep/ubuntu-sshd (带ssh的ubuntu)
地址:https://hub.docker.com/r/rastasheep/ubuntu-sshd/

sudo docker run -d -p 22:22 rastasheep/ubuntu-sshd:16.04

用户名、密码为root

镜像02:itscaro/debian-ssh (带ssh的ubuntu)
地址:https://hub.docker.com/r/itscaro/debian-ssh/

sudo docker run -d -p 22:22 itscaro/debian-ssh

用户名、密码为root

镜像03:tutum/centos (带ssh的centos)
地址:https://hub.docker.com/r/tutum/centos/

sudo docker run -d -p 22:22 tutum/centos

(centos7:tutum/centos:centos7 )
用户名root,
密码随机,请执行 docker logs 查看
这个作者还有好多好东西:https://hub.docker.com/r/tutum/centos/

镜像04:alexwhen/docker-2048(游戏2048)
地址:https://hub.docker.com/r/alexwhen/docker-2048/

sudo docker run -d -p 80:80 alexwhen/docker-2048

镜像05:dorowu/ubuntu-desktop-lxde-vnc(noVNC、Firefox51)
地址:https://hub.docker.com/r/dorowu/ubuntu-desktop-lxde-vnc/

docker run -it -p 80:80 dorowu/ubuntu-desktop-lxde-vnc

Browse http://localhost/

镜像06:consol/centos-xfce-vnc (VNC、noVNC、密码、chrome、Firefox45)
地址:https://hub.docker.com/r/consol/ubuntu-xfce-vnc/

run -it -p 5901:5901 -p 6901:6901 -e “VNC_PW=my-new-password” -e VNC_RESOLUTION=800×600 consol/centos-xfce-vnc

默认VNC密码:vncpassword
VNC-Server (default VNC port 5901)
noVNC – HTML5 VNC client (default http port 6901)
其他相关

onsol/centos-xfce-vnc: Centos7 with Xfce4 UI session
consol/ubuntu-xfce-vnc: Ubuntu with Xfce4 UI session
consol/centos-icewm-vnc: dev Centos7 with IceWM UI session
consol/ubuntu-icewm-vnc: dev Ubuntu with IceWM UI session

镜像07:fish/peerflix-server (支持磁力,种子)
地址:https://hub.docker.com/r/fish/peerflix-server

docker run -it -p 9000:9000 fish/peerflix-server

Browse http://localhost:9000/

镜像08:jpillora/cloud-torrent(种子下载,搜索)
地址:https://hub.docker.com/r/jpillora/cloud-torrent/

docker run -d -p 3000:3000 -v /path/to/my/downloads:/downloads jpillora/cloud-torrent

Browse http://localhost:3000/

镜像09:jim3ma/google-mirror(google镜像,如需ssl要手动添加)
地址:https://hub.docker.com/r/jim3ma/google-mirror/

docker run -d -p 80:80 jim3ma/google-mirror

Browse http://localhost:80/

镜像⒑:google-reverse-proxy(google镜像,有ssl)
地址:https://hub.docker.com/r/jokester/google-reverse-proxy/

docker run -d –publish 54321:20081 –restart=always jokester/google-reverse-proxy

Browse https://ip:54321/

镜像⒒:forsaken-mail(临时邮箱)
地址:https://hub.docker.com/r/rockmaity/forsaken-mail/

docker run –name forsaken-mail -itd -p 25:25 -p 3000:3000 rockmaity/forsaken-mail

Browse http://ip:3000/

镜像⒓:imdjh/owncloud-with-ocdownloader(owncloud,torrent,aria2,youtube-dl)
地址:https://hub.docker.com/r/imdjh/owncloud-with-ocdownloader/

docker run -d -p 80:80 -e OWNCLOUD_VERSION=9.1.4 -v /var/www/html/data:/var/www/html/data imdjh/owncloud-with-ocdownloader

Browse http://ip/

镜像⒔:v2ray/official(v2ray)
地址:https://hub.docker.com/r/v2ray/official/

docker run -d -p 8001:8001 v2ray/official

镜像⒕:timonier/aria2
地址:https://hub.docker.com/r/timonier/aria2/

docker run -i -t -v /data:/data –net host timonier/aria2 –dir=/data –enable-rpc –rpc-listen-all=true

配合使用:timonier/webui-aria2(aria2web管理)
地址:https://hub.docker.com/r/timonier/webui-aria2/

docker run -i -t -p 80:80 timonier/webui-aria2

原文: http://blog.jialezi.net/?post=35