Nginx反向代理Google扩展ngx_http_google_filter_module

admin8年前技术文档2420

模块介绍

ngx_http_google_filter_module 是一个过滤器模块,能够让谷歌镜像更便捷的部署。内建了正则表达式、URI locations和其他复杂的配置。原生nginx模块确保了更加高效地处理cookies, gstatic scoures和重定向。

最近发现之前搭建的《Nginx发现代理Google》不好用,查找方法发现一个更好方法,直接安装Nginx模块即可。

地址:https://github.com/cuber/ngx_http_google_filter_module

(或者也可以选择nginx官网源码安装:http://nginx.org/en/download.html)

模块介绍

ngx_http_google_filter_module 是一个过滤器模块,能够让谷歌镜像更便捷的部署。内建了正则表达式、URI locations和其他复杂的配置。原生nginx模块确保了更加高效地处理cookies, gstatic scoures和重定向。

安装Nginx

使用《OneinStack》Nginx选择y,其余n

重新编译Nginx,安装ngx_http_google_filter_module模块

git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_modulecd /root/oneinstack/src
git clone https://github.com/cuber/ngx_http_google_filter_module
wget http://mirrors.linuxeye.com/oneinstack/src/pcre-8.38.tar.gz
wget http://mirrors.linuxeye.com/oneinstack/src/openssl-1.0.2h.tar.gz
tar xzf pcre-8.38.tar.gz
tar xzf openssl-1.0.2h.tar.gz
tar xzf nginx-1.10.1.tar.gz
cd nginx-1.10.1./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module \--with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module--with-http_realip_module --with-http_flv_module --with-openssl=../openssl-1.0.2h \--with-pcre=../pcre-8.38 --with-pcre-jit --with-ld-opt='-ljemalloc' \--add-module=../ngx_http_google_filter_module \--add-module=../ngx_http_substitutions_filter_module
make
mv /usr/local/nginx/sbin/nginx{,_`date +%m%d`}  #备份现有nginx
cp objscp objs/nginx /usr/local/nginx/sbin/  #更新nginx

nginx -t  #检查nginx语法

/usr/local/nginx/sbin/nginx //启动
/usr/local/nginx/sbin/nginx -s reload   //重启

更改配置文件



vi /usr/local/nginx/conf/vhost/demo.linuxeye.com.conf,保持内容如下:

server {
listen 443 ssl http2;
server_name sea.yuyunhe.cn;

    listen 443;
    ssl on;
    ssl_certificate   /cert/sea.yuyunhe.cn/214232195260891.pem;
    ssl_certificate_key  /cert/sea.yuyunhe.cn/214232195260891.key;
    ssl_session_timeout 5m;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
location / {
google on;
google_scholar on;  #google_scholar 依 赖于 google, 所以 google_scholar 无法独立使用。由于谷歌学术近日升级, 强制使用 https 协议, 并且 ncr 已经 支持, 所以不再需要指定谷歌学术的 tld
google_language en;  #语言偏好,默认使用 zh-CN (中文)
}
}

server {
listen 80;
server_name demo.linuxeye.com;
rewrite ^(.*)$ https://$host$1 permanent; #访问http跳转至https
}
保持配置文件重启nginx:
/usr/local/nginx/sbin/nginx -s reload

测试:

预览地址:https://sea.yuyunhe.cn

image.png

分享到:

相关文章

CROS实现跨域时授权问题(401错误)的解决

Spring+Shrio的解决方案shiro中可以在自己实现的身份验证filter中加入以下代码:@Override   protected boolean ...

Cenots上elasticsearch安装与使用

Cenots上elasticsearch安装与使用

安装java环境懒人模式:yum install java*简单配置下:vim /etc/profile尾部加上:export JAVA_HOME=/usr/lib/jvm/java-1.8...

用PHP发送POST请求

/**  * 发送post请求  * @param string $url 请求地址  * @param...

MYSQL IS NOT RUNNING, BUT LOCK FILE (/VAR/LOCK/SUBSYS/MYSQL) EXISTS

[root@admin-node subsys]# service mysql startStarting MySQL. ERROR! [root@admin-node subsys]# servic...

ThinkPHP实现多数据库连接的解决方法

这篇文章主要介绍了ThinkPHP实现多数据库连接的解决方法,需要的朋友可以参考下ThinkPHP实现连接多个数据的时候,如果数据库在同一个服务器里的话只需要这样定义模型:?123class Memb...

PhpExcel中文帮助手册|PhpExcel使用方法

PhpExcel中文帮助手册|PhpExcel使用方法

phpexcel 下载:hongweizhiyuan-phpexcel-master.zip下面是总结的几个使用方法include 'PHPExcel.php';include ...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。