
前阵子在 vps 上弄了一个中文维基百科的反向代理,但是一直存在手机端不能用的问题(会跳转到手机版的维基百科)。刚刚终于把这个问题解决掉了: https://w.sxisa.org
https 的证书是用的 Let's Encrypt
下面是 nginx 的配置:
server { server_name w.sxisa.org; listen 80; rewrite ^/(.*) https://$server_name/$1 permanent; } server { server_name w.sxisa.org; listen 443; ssl on; ssl_certificate 证书; ssl_certificate_key 证书; location / { proxy_pass https://zh.wikipedia.org; proxy_buffering off; proxy_cookie_domain zh.wikipedia.org w.sxisa.org; proxy_redirect https://zh.wikipedia.org/ /; proxy_redirect https://zh.m.wikipedia.org/ https://m.w.sxisa.org/; proxy_set_header X-Real_IP $remote_addr; proxy_set_header User-Agent $http_user_agent; proxy_set_header Accept-Encoding ''; proxy_set_header referer "https://zh.wikipedia.org$request_uri"; subs_filter_types text/css text/xml text/Javascript; subs_filter '维基百科' '创软维基百科镜像'; subs_filter zh.wikipedia.org w.sxisa.org; subs_filter upload.wikimedia.org up.w.sxisa.org; subs_filter zh.m.wikipedia.org m.w.sxisa.org; } location https://zh.m.wikipedia.org/{ rewrite ^/(.*) https://m.w.sxisa.org/$1 permanent; } } server { server_name m.w.sxisa.org; listen 80; rewrite ^/(.*) https://$server_name/$1 permanent; } server { server_name m.w.sxisa.org; listen 443; ssl on; ssl_certificate 证书; ssl_certificate_key 证书; location / { proxy_pass https://zh.m.wikipedia.org; proxy_buffering off; proxy_redirect https://zh.m.wikipedia.org/ /; proxy_cookie_domain zh.m.wikipedia.org m.w.sxisa.org; proxy_set_header X-Real_IP $remote_addr; proxy_set_header User-Agent $http_user_agent; proxy_set_header Accept-Encoding ''; proxy_set_header referer "https://zh.m.wikipedia.org$request_uri"; subs_filter_types text/css text/xml text/Javascript; subs_filter '维基百科' '创软维基百科镜像'; subs_filter zh.wikipedia.org w.sxisa.org; subs_filter zh.m.wikipedia.org m.w.sxisa.org; subs_filter upload.wikimedia.org up.w.sxisa.org; } } server { server_name up.w.sxisa.org; listen 80; rewrite ^/(.*) https://$server_name/$1 permanent; } erver { server_name up.w.sxisa.org; listen 443; ssl on; ssl_certificate 证书; ssl_certificate_key 证书; location / { proxy_pass https://upload.wikimedia.org; proxy_cookie_domain upload.wikimedia.org up.w.sxisa.org; proxy_buffering off; proxy_set_header X-Real_IP $remote_addr; proxy_set_header User-Agent $http_user_agent; proxy_set_header referer "https://upload.wikimedia.org$request_uri"; } } 1 Tink PRO 我也反代了一个,手机版貌似也有问题,就没管 |
2 just1 2016 年 1 月 9 日 via Android 做一个通用反代规则就可以了,所以网站自动反代 |
3 marenight 2016 年 1 月 9 日 手机浏览器拦截了,报告隐私风险。 |
4 Zohar 2016 年 1 月 9 日 |
5 chunchu 2016 年 1 月 9 日 via iPhone 最下面的 server 前面少了一个字母 s |
6 leakeung 2016 年 1 月 9 日 过断 mark 赞 |
7 imlinhanchao OP |
8 chunchu 2016 年 1 月 9 日 期待楼主对所有语言的反代 |
9 Khlieb 2016 年 1 月 9 日 via Android |
10 bdbai 2016 年 1 月 9 日 via iPhone 感觉中文版只是 DNS 污染,换个 DNS 就能访问了。 |
11 imlinhanchao OP @bdbai 用 hosts 确实可以访问,不过图片不知道为啥看不了。 |
12 bdbai 2016 年 1 月 9 日 via iPhone @imlinhanchao 图片用的域名也得改 host ,不过改个 DNS 就一劳永逸了。 |
14 Guenlay 2016 年 1 月 9 日 multy subs_filter 似乎是 1.9.3 以后才支持 |
15 Slienc7 2016 年 1 月 9 日 为何不直接上数据库做镜像。 |
16 chunchu 2016 年 1 月 9 日 nginx version: nginx/1.9.3 测试了一下,图片不能正确显示,我看楼主的图片可以正常显示,不知道是什么原因。 |
17 chunchu 2016 年 1 月 9 日 找到原因了,我的 wildcard 只能对*.xxx.org 有效,对 up.w.xxx.org 不能识别为安全连接 |
20 Khlieb 2016 年 1 月 10 日 via Android |
21 Khlieb 2016 年 5 月 7 日 via Android 手机版 502 了 |
22 Khlieb 2016 年 6 月 21 日 全站 404 了 |
23 imlinhanchao OP @chunchu https://github.com/imlinhanchao/ngx_proxy_wiki 所有语言的反代。(时隔多年,终于填坑 |
24 Michael2002 2017 年 2 月 14 日 @bdbai 怎么改 DNS ? |
25 bdbai nbsp; 2017 年 2 月 14 日 via Android @Michael2002 网上搜一下公共 DNS |
26 Michael2002 2017 年 3 月 23 日 @bdbai 换什么 DNS 呢? |
27 Michael2002 2017 年 3 月 23 日 @bdbai 感觉很多 DNS 都不咋地 |
28 Michael2002 2017 年 4 月 21 日 @bdbai 在吗? |