本文假设你是一个全新的服务器,且IP没有被墙,如果你本身已经装好了服务器,可直接配置反向代理
- 首先你需要有一个境外的VPS,很容易搞到
- 下载必要环境
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
- 编译安装
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
- 配置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";
}
}
- 启动nginx
/usr/www/server/nginx-1.7.8/sbin/nginx -c /usr/www/server/nginx-1.7.8/conf/nginx.conf
- 使用IP访问一下试试吧