演示地址
阿蔡自建的Google镜像,Wikipedia镜像(无移动端)
反向代理原理
反向代理(Reverse Proxy)是指以代理服务器来接受Internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给Internet上请求连接的客户端,此时代理服务器对外就表现为一个反向代理服务器,简言之就是通过我的服务器去访问GFW外的网站
实现反向代理
确保你已经编译安装了Nginx,并且将ngx_http_substitutions_filter_module
和ngx_http_google_filter_module
两个模块进行了编译,更多参考
本人的谷歌镜像站的nginx.conf
设置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
#PROXY-START location / { proxy_pass https://www.google.com.hk; proxy_set_header Host www.google.com.hk; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; #持久化连接相关配置 #proxy_connect_timeout 30s; #proxy_read_timeout 86400s; #proxy_send_timeout 30s; #proxy_http_version 1.1; #proxy_set_header Upgrade $http_upgrade; #proxy_set_header Connection "upgrade"; add_header X-Cache $upstream_cache_status; proxy_set_header Accept-Encoding ""; sub_filter "手气不错" "阿蔡不菜"; sub_filter_once off; expires 12h; } location ~ .*\.(php|jsp|cgi|asp|aspx|flv|swf|xml)?$ { proxy_set_header Host www.google.com.hk; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; proxy_pass https://www.google.com.hk; proxy_set_header Accept-Encoding ""; sub_filter "手气不错" "阿蔡不菜"; sub_filter_once off; } location ~ .*\.(html|htm|png|gif|jpeg|jpg|bmp|js|css)?$ { proxy_set_header Host www.google.com.hk; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; proxy_pass https://www.google.com.hk; #缓存相关配置 proxy_cache cache_one; proxy_cache_key $host$request_uri$is_args$args; proxy_cache_valid 200 304 301 302 1h; proxy_set_header Accept-Encoding ""; sub_filter "手气不错" "阿蔡不菜"; sub_filter_once off; expires 24h; } #PROXY-END |
常见参数和释义,更多参考
Directive | Explanation |
proxy_connect_timeout | 向上游服务器请求超时时间 |
proxy_cookie_domain | 将请求头中 Set-Cookie 头内容替换成新域名 |
proxy_cookie_path | 替换 Set-Cookie 中路径 |
proxy_pass | 上游服务器 URL |
proxy_set_header | 修改请求 headers |
proxy_redirect | 反向代理的重定向指令 |
subs_filter | 内容替换 |
1 2 3 |
sub_filter <body '<div style="border: red 1px solid;width: 100px;text-align: center;line-height: 30px;height: 30px;font-size: 14px;z-index: 999999999;position: fixed;top: 80px;font-weight: bold;background-color: yellow;left: 10px;">测试服务器</div><body'; sub_filter_once off; sub_filter_types application/json application/x-javascript text/plain; |
延伸拓展
阿蔡还试过反向代理Youtube和Instagram等,但以失败告终,这些站点的图片流和视频流并不能简单的以Nginx反代配置就能实现的,而且做反代的意义也不大,毕竟有境外的服务器直接搭个SSR服务就行,IG我没有找到相关的教程,Youtube倒是有代理其视频流的教程除了代理浏览GFW之外的网站,如果你在不同的地方都有服务器,那么也可以使用Nginx反向代理实现CDN内容分发,相关参考https://www.cnblogs.com/lidabo/p/7418578.html,https://www.moerats.com/archives/575/,http://duimin.com/105.html
写在后面
毕竟这只是镜像站点,通过我的Google搜索里的链接到GFW之外的网站如Youtube,Facebook等依然上不去,维基百科也没有做移动端的代理,要实现全面的体验还得依靠SS,SSR,V2ray等的全局HTTP代理,当然更好的是期待着高墙瓦解的那一天
© 著作权归作者所有
文章评论(1)
Great content! Super high-quality! Keep it up! :)