nginx反向代理google的经验


CENTOS下安装LNMP后,默认是不带反向代理所需要的模块的,需要增加第三方模块,
根据https://github.com/cuber/ngx_http_google_filter_module/blob/master/README.zh-CN.md总结的方法如下:
cd /root/lnmp1.2-full/src #进入LNMP安装目录
git clone https://github.com/cuber/ngx_http_google_filter_module #下载模块
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module #下载模块
cd nginx-1.7.8 #进入NGINX目录
make clean #清除以前的配置
#编译配置
./configure \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_spdy_module \
--with-http_gzip_static_module \
--with-ipv6 \
--with-http_sub_module\
#以上为LNMP安装自带的模块,需要加入以下两行
--add-module=../ngx_http_google_filter_module \
--add-module=../ngx_http_substitutions_filter_module
make && make install #即可安装完成.

最后新建一个虚拟主机配置文件,删除原来的内容,填入如下内容:

server {
listen 443 ssl;
server_name gg.zhtube.com;

ssl on;
ssl_certificate gg.zhtube.com.crt;
ssl_certificate_key gg.zhtube.com.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;
keepalive_timeout 70;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;

resolver 8.8.8.8;

location / {
google on;
}
}

证书可以自行添加,以后有时间写个获取证书的内容,最后效果如网站演示:

https://gg.zhtube.com/

也可以在浏览器中加入自定义搜索如下内容:

https://gg.zhtube.com/search?num=50&hl=zh-cn&newwindow=1&c2coff=1&safe=off&q=%s


发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注