从零开始用nginx反向代理搭建google镜像

本文假设你是一个全新的服务器,且IP没有被墙,如果你本身已经装好了服务器,可直接配置反向代理

  1. 首先你需要有一个境外的VPS,很容易搞到
  2. 下载必要环境
yum install -y gcc gcc-c++ git make
wget "http://nginx.org/download/nginx-1.7.8.tar.gz"
wget "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz"
wget "https://www.openssl.org/source/openssl-1.0.1j.tar.gz"
wget "https://www.openssl.org/source/openssl-1.0.1j.tar.gz"
wget "http://zlib.net/zlib-1.2.11.tar.gz"
git clone https://github.com/cuber/ngx_http_google_filter_module
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module

解压

tar xzvf nginx-1.7.8.tar.gz 
tar xzvf pcre-8.38.tar.gz 
tar xzvf openssl-1.0.1j.tar.gz 
tar xzvf zlib-1.2.11.tar.gz
  1. 编译安装
cd nginx-1.7.8
./configure --prefix=/usr/www/server/nginx-1.7.8 --with-pcre=../pcre-8.38 --with-openssl=../openssl-1.0.1j --with-zlib=../zlib-1.2.11 --with-http_ssl_module --add-module=../ngx_http_google_filter_module --add-module=../ngx_http_substitutions_filter_module
make && make install
  1. 配置nginx
/usr/www/server/nginx-1.7.8/sbin/nginx -t
vi /usr/www/server/nginx-1.7.8/conf/nginx.conf
server {
    listen       80;
    server_name  121.xxx.xxx.xxx; #此处换成该vps的外网ip
     location / {
        proxy_pass https://www.google.com;
        proxy_connect_timeout 120;
        proxy_read_timeout 600;
        proxy_send_timeout 600;
        send_timeout 600;
        proxy_redirect    off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        google on;
        google_language "zh-CN";
       }
  }
  1. 启动nginx
/usr/www/server/nginx-1.7.8/sbin/nginx -c /usr/www/server/nginx-1.7.8/conf/nginx.conf
  1. 使用IP访问一下试试吧
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容