主页
文章
分类
系列
标签
Google 镜像站
发布于: 2019-2-16   更新于: 2019-2-16   收录于: Backend , 镜像
文章字数: 138   阅读时间: 1 分钟  

通过 Nginx 反向代理搭建 Google 镜像站

Nginx 配置文件添加如下配置

 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
server {
	listen 80;

	server_name www.example.com;

	location / {
		proxy_pass https://www.google.com/;

		proxy_redirect https://www.google.com/ /;
		# proxy_redirect off;
		proxy_cookie_domain google.com www.example.com;

		proxy_set_header Host "www.google.com";
		proxy_set_header Referer https://www.google.com;
		proxy_set_header Accept-Encoding "";
		proxy_set_header Accept-Language "en-US";
		proxy_set_header User-Agent $http_user_agent;
		
		proxy_set_header X-Real-IP $remote_addr;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header X-Forwarded-Proto https;

		# 这里替换网页中的链接
		subs_filter  http://www.google.com http://www.example.com;
		subs_filter  https://www.google.com https://www.example.com;
		sub_filter_once off;
	}
}

把域名 example 替换成自己的域名后重新加载配置即可

Andy
Welcome to andy blog
目录