最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Ubuntu 14.04利用Nginx反代理Google
时间:2022-06-30 19:15:37 编辑:袖梨 来源:一聚教程网
1.安装相关软件
#
# 安装 gcc & git
apt-get install build-essential git gcc g++ make
# 下载Nginx最新版源码
# http://nginx.org/en/download.html
wget "http://nginx.org/download/nginx-1.9.2.tar.gz"
# 下载最新版 pcre
# http://www.pcre.org/
wget "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz"
# 下载最新版 openssl
# https://www.openssl.org/
wget "https://www.openssl.org/source/openssl-1.0.2c.tar.gz"
# 下载最新版 zlib
# http://www.zlib.net/
wget "http://zlib.net/zlib-1.2.8.tar.gz"
# 下载本扩展
git clone https://github.com/cuber/ngx_http_google_filter_module
# 下载 substitutions 扩展
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
# 解压缩
tar xzvf nginx-1.9.2.tar.gz
tar xzvf pcre-8.36.tar.gz
tar xzvf openssl-1.0.2c.tar.gz
tar xzvf zlib-1.2.8.tar.gz
# 进入 nginx 源码目录
cd nginx-1.9.2
# 设置编译选项
./configure
--prefix=/opt/nginx-1.9.2
--with-pcre=../pcre-8.36
--with-openssl=../openssl-1.0.2c
--with-zlib=../zlib-1.2.8
--with-http_ssl_module
--add-module=../ngx_http_google_filter_module
--add-module=../ngx_http_substitutions_filter_module
make
sudo make install
# 启动Nginx
sudo /opt/nginx-1.9.2/sbin/nginx
2.配置Nginx
编辑/opt/nginx-1.9.2/conf/nginx.conf
我的配置如下,红色部分为修改/追加于默认配置的内容
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
#强制http跳转https
listen 80;
server_name 域名;
rewrite ^/(.*) https://域名/$1 permanent;
}
server {
listen 443;
server_name 域名;
ssl on;
ssl_certificate 证书.crt路径;
ssl_certificate_key 证书.key路径;
resolver 8.8.8.8;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
#添加Google和Google学术支持,重要!
google on;
google_scholar on;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
最后重载一下Nginx的配置,应该就能看到Google的页面了。
/opt/nginx-1.9.2/sbin/nginx -s reload
相关文章
- 无限暖暖搭乘大鸟巴士怎么玩 公测第三天每日任务做法介绍 12-27
- 奇迹暖暖绚光护佑搭配攻略 奇迹暖暖绚光护佑过关攻略 12-27
- 绝区零月城柳意像影画怎么样 12-27
- 无限暖暖翩翩愿飞去怎么样 12-27
- 黑神话悟空1.0.12.16581版本更新公告 12-27
- 光遇12.27红石碎片在哪里 12-27