最新下载
热门教程
- 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://ngi*nx.*or*g/en/download.html
wget "http://*ng*inx.org*/download/nginx-1.9.2.tar.gz"
# 下载最新版 pcre
# http://www.p***cre.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.open***ssl.org/source/openssl-1.0.2c.tar.gz"
# 下载最新版 zlib
# http://www.*z**lib.net/
wget "http://zli*b.n**et/zlib-1.2.8.tar.gz"
# 下载本扩展
git clone https://github.*co**m/cuber/ngx_http_google_filter_module
# 下载 substitutions 扩展
git clone https://gith**ub.c*om/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
相关文章
- 炉石传说标准模式元素法卡组推荐分享 11-04
 - 炉石传说烟花元素法上分卡组推荐分享 11-04
 - 炉石传说标准模式星舰补水德卡组分享 11-04
 - 炉石传说深暗领域版本蛋猎卡组分享 11-04
 - 梦幻西游法宝合成公式是什么-法宝合成公式大全 11-04
 - 过山车之星2安排工作时间表作用介绍 11-04