前言

最近查资料的时候深刻感觉到国内的搜索引擎已经不做人了,搜索结果基本都是广告和水文,所以有必要换用更简洁、搜索质量更好的搜索引擎。从我的使用情况来看Google搜索的质量高于必应搜索,但是上网工具有时不方便,故搭建镜像站,自己查资料用用。

准备工作

需要一个能正常访问Google的服务器

需要能正常解析的域名

安装NginX

CentOS 7+:

1
rpm -ivh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.18.0-1.el7.ngx.x86_64.rpm

Ubuntu:

1
2
apt update
apt install nginx

安装完成后启动nginx

1
systemctl start nginx

浏览器访问服务器公网ip,出现”Welcome to nginx!”则代表nginx已经启动。

配置反向代理

1
2
cd /etc/nginx/conf.d
vim google.example.com.conf

内容为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
server {
listen 80;
server_name google.example.com;

location / {
proxy_pass https://www.google.com;
proxy_connect_timeout 120;
proxy_read_timeout 600;
proxy_send_timeout 600;
send_timeout 600;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}
}

其中google.example.com是镜像站使用的域名,需要域名解析到服务器

重启nginx

1
systemctl restart nginx

至此大功告成!镜像站搭建完成了!