proxy_cache_path /var/nginx/cache/one levels=1:2 keys_zone=one:10m max_size=2g;
proxy_cache_key "$host$request_uri";
upstream google {
server 74.125.224.71:80 max_fails=3;
server 74.125.224.72:80 max_fails=3;
server 74.125.224.73:80 max_fails=3;
server 74.125.224.74:80 max_fails=3;
server 74.125.224.75:80 max_fails=3;
server 74.125.224.76:80 max_fails=3;
server 74.125.224.77:80 max_fails=3;
server 74.125.224.78:80 max_fails=3;
server 74.125.224.79:80 max_fails=3;
server 74.125.224.80:80 max_fails=3;
}
server {
listen 80;
server_name $你将要代理的 google 的域名$;
rewrite ^(.*) https://$你将要代理的 google 的域名$$1 permanent;
}
server {
listen 443;
server_name $你将要代理的 google 的域名$;
ssl on;
ssl_certificate 你的 ssl 证书.crt;
ssl_certificate_key 你的 ssl 密钥.key;
location /{
proxy_cache one;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 404 1m;
proxy_redirect https://www.google.com/ /;
proxy_cookie_domain google.com $你将要代理的 google 的域名$;
proxy_pass http://google;
proxy_set_header Host "www.google.com";
proxy_set_header Accept-Encoding "";
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Language "zh-CN";
proxy_set_header Cookie "PREF=ID=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2W1IQ-Maw";
sub_filter www.google.com $你将要代理的 google 的域名$;
sub_filter_once off;
}
}
以上,请将$你将要代理的google的域名$替换为你反向代理的 google 的域名,如 g.foo.bar;请将/var/nginx/cache/one替换为你的nginx缓存目录,max_size为缓存区大小,随便你设置吧;upstream google段是设置的google原始可正常访问的ip的负载均衡;反向代理中考虑到自动关键字提示,替换了对应的cookie;443需要替换对应的证书,当然你用自己签发的也没关系,我用的是sslstart的证书。
proxy_cache_key "$host$request_uri";
upstream google {
server 74.125.224.71:80 max_fails=3;
server 74.125.224.72:80 max_fails=3;
server 74.125.224.73:80 max_fails=3;
server 74.125.224.74:80 max_fails=3;
server 74.125.224.75:80 max_fails=3;
server 74.125.224.76:80 max_fails=3;
server 74.125.224.77:80 max_fails=3;
server 74.125.224.78:80 max_fails=3;
server 74.125.224.79:80 max_fails=3;
server 74.125.224.80:80 max_fails=3;
}
server {
listen 80;
server_name $你将要代理的 google 的域名$;
rewrite ^(.*) https://$你将要代理的 google 的域名$$1 permanent;
}
server {
listen 443;
server_name $你将要代理的 google 的域名$;
ssl on;
ssl_certificate 你的 ssl 证书.crt;
ssl_certificate_key 你的 ssl 密钥.key;
location /{
proxy_cache one;
proxy_cache_valid 200 302 1h;
proxy_cache_valid 404 1m;
proxy_redirect https://www.google.com/ /;
proxy_cookie_domain google.com $你将要代理的 google 的域名$;
proxy_pass http://google;
proxy_set_header Host "www.google.com";
proxy_set_header Accept-Encoding "";
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Accept-Language "zh-CN";
proxy_set_header Cookie "PREF=ID=047808f19f6de346:U=0f62f33dd8549d11:FF=2:LD=zh-CN:NW=1:TM=1325338577:LM=1332142444:GM=1:SG=2:S=rE0SyJh2W1IQ-Maw";
sub_filter www.google.com $你将要代理的 google 的域名$;
sub_filter_once off;
}
}
以上,请将$你将要代理的google的域名$替换为你反向代理的 google 的域名,如 g.foo.bar;请将/var/nginx/cache/one替换为你的nginx缓存目录,max_size为缓存区大小,随便你设置吧;upstream google段是设置的google原始可正常访问的ip的负载均衡;反向代理中考虑到自动关键字提示,替换了对应的cookie;443需要替换对应的证书,当然你用自己签发的也没关系,我用的是sslstart的证书。