我的博客
欢迎来到我的博客
bunny.icu

搭建Google、Wikipedia镜像站

搭建Google、Wikipedia镜像站

使用Docker搭建Google镜像

docker run --name onemirror -p 10001:80 -d bohan/onemirror

Nginx反向代理Google和Wikipedia

vim nginx/conf/nginx.conf
user            root;
worker_processes    1;

events {
    worker_connections    1024;
}

http {
    include                mime.types;
    include                vhost/*.conf;
    default_type           application/octet-stream;
    sendfile               on;
    client_max_body_size   100M;
    keepalive_timeout      60;
    large_client_header_buffers    4 100k;
    ssl_certificate        /root/nginx/ssl/_.bunny.icu_chain.crt;
    ssl_certificate_key    /root/nginx/ssl/_.bunny.icu_key.key;
    sub_filter_once        off;
    gzip                   off;

    server {
        listen            80;
        server_name       *.bunny.icu;
        rewrite ^(.*)$    https://$host$1 permanent;
    }

    # Reference: https://zhuanlan.zhihu.com/p/79825610
    server {
        listen               443 ssl;
        server_name          gg.bunny.icu;

        location / {

            #proxy_pass       https://www.google.com/;
            proxy_pass       http://localhost:10001/;
            #proxy_pass       https://gg1.wangshaogang.com/;
            #proxy_redirect   https://www.google.com/ /;
            proxy_cookie_domain google.com gg.bunny.icu;
            proxy_set_header User-Agent $http_user_agent;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Accept-Encoding "";

            subs_filter  www.google.com gg.bunny.icu;
            subs_filter  zh.wikipedia.org wp.bunny.icu;
            subs_filter  zh.m.wikipedia.org wpm.bunny.icu;

        }
    }


    server {
        listen               443 ssl;
        server_name          gg1.bunny.icu;
        location / {
            proxy_pass       https://www.google.com/;
        }

    }

    server {
        listen               443 ssl;
        server_name          wp.bunny.icu;
        if ($http_user_agent ~* (android|ip(ad|hone|od)|kindle|blackberry|windows\s(ce|phone))) {
            rewrite ^(.*)$   https://wpm.bunny.icu/;
        }
        location / {
            proxy_pass       https://zh.wikipedia.org/;
            proxy_redirect   https://zh.wikipedia.org/ /;
            proxy_cookie_domain wikipedia.org wp.bunny.icu;
            proxy_set_header User-Agent $http_user_agent;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            sub_filter  https://zh.wikipedia.org https://wp.bunny.icu;
        }
    }

    server {
        listen               443 ssl;
        server_name          wpm.bunny.icu;
        location / {
            proxy_pass       https://zh.m.wikipedia.org/;
            proxy_redirect   https://zh.m.wikipedia.org/ /;
            proxy_cookie_domain wikipedia.org wp.bunny.icu;
            proxy_set_header User-Agent $http_user_agent;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            sub_filter  https://zh.m.wikipedia.org https://wpm.bunny.icu;
        }
    }

}



预览
https://gg.bunny.icu
https://gg1.bunny.icu
https://wp.bunny.icu
https://wpm.bunny.icu

Reference

Nginx 搭建 Google 镜像站 – 知乎
利用docker快速搭建个性化Google镜像
NGINX添加subs_filter模块
【nginx】sub_filter/subs_filter替换不生效的原因和解决方案
nginx sub_filter 不生效方案
nginx 替换网站响应内容

版权声明


本作品系原创, 转载须遵循 CC BY-NC-ND 4.0 许可协议
本文标题:搭建Google、Wikipedia镜像站
本文链接:https://www.bunny.icu/archives/1435

推荐文章

发表评论

textsms
account_circle
email

bunny.icu

搭建Google、Wikipedia镜像站
使用Docker搭建Google镜像 docker run --name onemirror -p 10001:80 -d bohan/onemirror Nginx反向代理Google和Wikipedia vim nginx/conf/nginx.conf user root; worke…
扫描二维码继续阅读
2022-07-29