共计 2691 个字符,预计需要花费 7 分钟才能阅读完成。
安装 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/\
header_down location (https://zh.m.wikipedia.org/)(.*) http://mzhwk.example.com/\
}
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" """" ""
}
}
移动站
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/\
header_down location (https://zh.m.wikipedia.org/)(.*) http://mzhwk.example.com/\
}
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" """" ""
}
}
静态资源
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。
添加广告
如果需要添加广告,请加入下面内容
"