使用 caddy 搭建一个维基百科的镜像并添加广告赚钱

18 天前
 chenjia404

安装 replace-response 模块

caddy add-package github.com/caddyserver/replace-response

Caddyfile

主站

http://zhwk.example.com {
        reverse_proxy * https://zh.wikipedia.org {
                header_up Host {upstream_hostport}
                header_up X-Real-IP {http.request.remote.host}
                header_up X-Forwarded-For {http.request.remote.host}
                header_up X-Forwarded-Port {http.request.port}
                header_up X-Forwarded-Proto {http.request.scheme}
                header_up Accept-Encoding identity
                header_down location ( https://zh.wikipedia.org/)(.*) https://zhwk.example.com/$2
                header_down location ( https://zh.m.wikipedia.org/)(.*) http://mzhwk.example.com/$2
        }

        replace {
                "upload.wikimedia.org" "upzhwk.example.com"
                "zh.wikipedia.org" "zhwk.example.com"
                "zh.m.wikipedia.org" "mzhwk.example.com"
                "/w/index.php?title=Special:%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95" ""
                "w/index.php?title=Special:%E5%88%9B%E5%BB%BA%E8%B4%A6%E6%88%B7" ""
                "action=edit" ""
                "</head>" "<style> .vector-menu-content-list,#ca-edit,#p-vector-user-menu-overflow,.mw-editsection{display: none;}</style></head>"
        }
}

移动站

http://mzhwk.example.com {
    reverse_proxy * https://zh.m.wikipedia.org {
                header_up Host {upstream_hostport}
                header_up X-Real-IP {http.request.remote.host}
                header_up X-Forwarded-For {http.request.remote.host}
                header_up X-Forwarded-Port {http.request.port}
                header_up X-Forwarded-Proto {http.request.scheme}
                header_up Accept-Encoding identity
                header_down location ( https://zh.wikipedia.org/)(.*) https://zhwk.example.com/$2
                header_down location ( https://zh.m.wikipedia.org/)(.*) http://mzhwk.example.com/$2
        }

        replace {
                "upload.wikimedia.org" "upzhwk.example.com"
                "zh.wikipedia.org" "zhwk.example.com"
                "zh.m.wikipedia.org" "mzhwk.example.com"
                "/w/index.php?title=Special:%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95" ""
                "w/index.php?title=Special:%E5%88%9B%E5%BB%BA%E8%B4%A6%E6%88%B7" ""
                "action=edit" ""
                "</head>" "<style> #page-actions-edit,.mw-editsection,#p-personal{display: none;}</style></head>"
        }
}

静态资源

http://upzhwk.example.com {
     reverse_proxy * https://upload.wikimedia.org {
                header_up Host {upstream_hostport}
                header_up X-Real-IP {http.request.remote.host}
                header_up X-Forwarded-For {http.request.remote.host}
                header_up X-Forwarded-Port {http.request.port}
                header_up X-Forwarded-Proto {http.request.scheme}
                header_up Accept-Encoding identity
        }
}

屏蔽了登录、注册、编辑功能,防止被恶意使用。

请将 example.com 替换成自己的域名,另外因为 cloudflare 不支持 多级子域名,所以移动站的一级子域名使用的 mzhwk 。

添加广告

如果需要添加广告,请加入下面内容

"</body>" "广告代码</body>"

注意事项

推荐廉价域名后缀

还有一些首年 1 美元的域名后缀,不过续费有一些贵,如果做一次性域名就很划算。

我搭建的一个样例: https://zhwk.kkwiki.win/ 不过没有加广告。

你们可以按教程搭建,然后加谷歌广告赚外汇。

原文: https://blog.chenjia.info/posts/2024/08/%E4%BD%BF%E7%94%A8caddy%E6%90%AD%E5%BB%BA%E4%B8%80%E4%B8%AA%E7%BB%B4%E5%9F%BA%E7%99%BE%E7%A7%91%E7%9A%84%E9%95%9C%E5%83%8F%E5%B9%B6%E6%B7%BB%E5%8A%A0%E5%B9%BF%E5%91%8A/

1680 次点击
所在节点    分享创造
3 条回复
cat9life
17 天前
是面向墙内的用户吗?
tbg
17 天前
真的可以赚吗😎
nmap
17 天前
难道不是秒被墙?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1069334

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX