Nginx反向代理,建立Google镜像
来源:互联网 发布:mysql联表删除 编辑:程序博客网 时间:2024/05/22 01:45
1. 准备一个可以访问google的服务器
可以考虑申请一个访问google不受限的云服务器,比如亚马逊。
2. 下载源码
wget http://artfiles.org/openssl.org/source/openssl-1.1.0e.tar.gzwget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gzwget http://zlib.net/zlib-1.2.11.tar.gzgit clone https://github.com/nginx/nginx.gitgit clone https://github.com/cuber/ngx_http_google_filter_modulegit clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
pcre版本不要太新,否则后面编译会有问题。
3. 编译安装
解压后,在nginx根目录下编译安装:
./auto/configure --with-pcre=../pcre-8.39 --with-openssl=../openssl-1.1.0e --with-zlib=../zlib-1.2.11 --with-http_ssl_module --add-module=../ngx_http_google_filter_module --add-module=../ngx_http_substitutions_filter_modulemake -j 4sudo make install
nginx默认安装目录是/usr/local/,
可执行文件/usr/local/nginx/sbin/nginx,
配置文件/usr/local/nginx/conf/nginx.conf
4. 修改nginx配置文件
server { server_name localhost; listen 80; resolver 8.8.8.8; location / { google on; }}
5. 启动nginx
sudo /usr/local/nginx/sbin/nginx
然后,就可以在浏览器上通过云主机的公网IP地址访问google了。
6. 用域名来访问
目前,我们能通过IP来访问,但是云服务器的IP地址不是固定的,所以, 可以考虑用域名来访问。
域名是之前申请的花生壳的一个免费域名。为了在IP地址变化时动态更新域名对应的IP地址,需要在服务器上定时检测IP地址的变化,并在变化的时候更新域名信息。
这里吐槽下花生壳在Linux下的官方客户端,试了几个版本,折腾了半天,最终还是无法使用。
我们通过下面的脚本来执行IP变化检测,并且在变化的时候更新域名信息。
并加入crontab 任务定时执行。
https://github.com/sigusr1/ph-ddns.git
7. 域名备案???
到这里,ping 域名也能正常ping通,域名对应的IP地址也正确,按理说至此域名已能正常工作。
遗憾的是,通过IP可以正常访问,通过域名就不可以。
在服务端和客户端抓包可以看到,被和谐了,有个“中间人”同时对Server和Client都发送了RST报文。
网络拓扑如下:
报文如下:
后来了解到,可能是因为域名未备案的原因,被墙了。
但是他们怎么实现的呢,通过IP可以访问,通过域名无法访问,猜测是通过HTTP头部的HOST字段来检测的。
8. 参考文档
https://www.meanevo.com/2015/08/20/mirrors-google-on-nginx/
http://linuxtools-rst.readthedocs.io/zh_CN/latest/tool/crontab.html
https://github.com/sigusr1/ph-ddns.git
- Nginx反向代理,建立Google镜像
- Nginx-----反向代理Google
- 利用nginx 反向代理 google
- nginx反向代理镜像网站做小偷站
- Nginx像Apache一样做反向代理
- Nginx反向代理Google扩展ngx_http_google_filter_module
- Nginx反向代理Nginx
- Nginx反向代理Nginx
- nginx反向代理google报错Permission denied
- Centos 6 下配置nginx 反向代理Google
- Nginx 配置 Google Fonts、Ajax 和 Gravatar 反向代理教程
- 反向代理到google
- nginx 反向代理
- nginx 反向代理
- Nginx 反向代理https
- Nginx 反向代理设置
- nginx反向代理
- nginx 反向代理上网
- OPencl学习笔记
- 数组运算的学习
- Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead
- Hibernate三种数据操作方式HQL-Criteria-Sql
- 排序算法---希尔排序
- Nginx反向代理,建立Google镜像
- 在网页中利用javascript实现动态时间的设计
- 【AtCoder Grand 013E】Placing Squares 题解
- Linux关机命令:halt shutdown reboot init
- 向死而生
- CSU 1870 Legendary
- bzoj 1001
- 机器学习(周志华)_第五章神经网络
- ArcGIS加载高德、OSM和谷歌等地图