奇特简易出国--出国了但没完全出国
ZYHWJL

404站

项目地址Nginx Module for Google Mirror

依赖库

  1. pcre 正则
  2. ngx_http_proxy_module 反向代理
  3. ngx_http_substitutions_filter_module 多重替换

Installation

Download sources first
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#
# download the newest source
# @see http://nginx.org/en/download.html
#
wget http://nginx.org/download/nginx-1.7.8.tar.gz

#
# clone ngx_http_google_filter_module
# @see https://github.com/cuber/ngx_http_google_filter_module
#
git clone https://github.com/cuber/ngx_http_google_filter_module

#
# clone ngx_http_substitutions_filter_module
# @see https://github.com/yaoweibin/ngx_http_substitutions_filter_module
#
git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
Brand new installation
1
2
3
4
5
6
7
8
#
# configure nginx customly
# replace </path/to/> with your real path
#
./configure \
<your configuration> \
--add-module=</path/to/>ngx_http_google_filter_module \
--add-module=</path/to/>ngx_http_substitutions_filter_module

宝塔安装

  1. 创建模块文件夹

  2. 下载库

    1
    2
    3
    4
    5
    6
    7
    git clone https://github.com/cuber/ngx_http_google_filter_module

    #
    # clone ngx_http_substitutions_filter_module
    # @see https://github.com/yaoweibin/ngx_http_substitutions_filter_module
    #
    git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module
  3. 安装

    软件商店–Nginx–配置

    踩坑点,Nginx高版本应使用–add-dynamic-module引入第三方模块

    1
    2
    --add-dynamic-module=</path/to/>ngx_http_google_filter_module \
    --add-module=</path/to/>ngx_http_substitutions_filter_module
  4. 使用

    1. 编辑Nginx配置文件,最上方加入

      踩坑点,Nginx高版本应手动引入第三方模块

    1
    load_module modules/ngx_http_google_filter_module.so;
    1. 编辑网站配置文件,加入
    1
    2
    3
    4
    resolver 8.8.8.8;
    location / {
    google on;
    }
    1. 注释,否则部分css,logo无法加载。原因:源站不存在静态资源,故关闭源站目录,全局反代。
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    server
    {
    # index index.php index.html index.htm default.php default.htm default.html;
    # root domain;

    #ERROR-PAGE-START 错误页配置,可以注释、删除或修改
    #error_page 404 /404.html;
    #error_page 502 /502.html;
    #ERROR-PAGE-END

    #PHP-INFO-START PHP引用配置,可以注释或修改
    # include enable-php-00.conf;
    #PHP-INFO-END

    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    # include /www/server/panel/vhost/rewrite/google.zyhwjl.cf.conf;
    #REWRITE-END

    # location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    # {
    # expires 30d;
    # error_log /dev/null;
    # access_log /dev/null;
    # }

    # location ~ .*\.(js|css)?$
    # {
    # expires 12h;
    # error_log /dev/null;
    # access_log /dev/null;
    # }

Github

编辑网站配置文件

1
2
3
4
5
6
7
8
9
10
location / {
proxy_set_header Accept-Encoding ""; #不使用压缩,如gzip
proxy_set_header Connection "";
proxy_http_version 1.1; #使用http1.1长连接
proxy_connect_timeout 10s; #设置连接超时
proxy_read_timeout 10s; #设置读取超时
proxy_set_header Host github.com;
proxy_hide_header Strict-Transport-Security; #隐藏协议头,避免因为反向代理开启hsts
proxy_pass https://github.com;
}

注释内容参照404网站