新建谷歌搜索镜像

某个晚上想到,自己 FQ 很多时候除了使用Gmail,还有很多时候只是用搜索,既然现在自己有这么都闲置域名和限制 VPS,那么就搭建一个谷歌镜像吧,也方便在不能 FQ 时临时查找资料。

步骤如下,后面慢慢补充。

更新记录

  1. 2018年1月28日,搭建成功
  2. 2018年1月30日,发现通过域名访问时,偶尔会有异常返回:

gg.mydomain.com 未发送任何数据。
ERR_EMPTY_RESPONSE

解决方法:HTTP 80 访问时的转发 rewrite 改为如下配置。

链接:In Nginx, how can I rewrite all http requests to https while maintaining sub-domain?

1
2
3
4
5
server {
listen 80;
server_name my.domain.com;
return 301 https://$server_name$request_uri;
}

安装过程

VPS 上安装 Python

VPS 上安装 nginx

配置 nginx 反向代理

开启 HTTPS

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#useir  nobody;
worker_processes 1;
worker_rlimit_nofile 65536;
#error_log logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info;

events {
worker_connections 1024;
}

http {
charset utf-8;
include mime.types;
default_type application/octet-stream;
access_log logs/access.log;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 6;
gzip_types text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml;
gzip_vary on;

server {
listen 80;
server_name mydomain.com;
resolver 8.8.8.8;

# http to https
location / {
#google on;
rewrite ^/(.*)$ https://mydomain.com$1 permanent;
}
}

server {
listen 443 ssl;
resolver 8.8.8.8;
server_name mydomain.com;

ssl on;
ssl_certificate /etc/ssl/private/my_crt_name.crt;
ssl_certificate_key /etc/ssl/private/my_key_name.key;
access_log off;
error_log off;

#forbid spider
if ($http_user_agent ~* "qihoobot|Baiduspider|Googlebot|Googlebot-Mobile|Googlebot-Image|Mediapartners-Google|Adsbot-Google|Feedfetcher-Google|Yahoo! Slurp|Yahoo! Slurp China|YoudaoBot|Sosospider|Sogou spider|Sogou web spider|MSNBot|ia_archiver|Tomato Bot") {
return 403;
}

#forbid illegal domain
#if ( $host != "<domain.name>" ) {
# return 403;
#}

location / {
google on;
google_scholar on;
google_language "zh-CN";
}
}

upstream google {
server 199.16.156.7:443;
server 31.13.64.1:443;
server 31.13.65.18:443;
server 31.13.69.160:443;
server 31.13.70.1:443;
server 31.13.74.1:443;
server 31.13.77.33:443;
server 31.13.80.17:443;
server 31.13.83.16:443;
server 31.13.83.8:443;
server 31.13.84.1:443;
server 31.13.97.245:443;
server 64.13.192.76:443;
server 64.13.192.76:443;
server 66.220.152.28:443;
server 67.228.102.32:443;
server 69.171.229.11:443;
server 69.171.237.16:443;
server 69.171.245.49:443;
server 69.63.176.59:443;
server 74.86.12.172:443;
server 75.126.2.43:443;
server 93.46.8.89:443;
# add more servers here
}
}
作者

Yves

发布于

2018-01-31

更新于

2018-01-31

许可协议