为了能够正常访问google进行搜索,之前一直用的ssh转socks代理。后来觉得如果s2主机只用来做代理,有点浪费了。于是就想了干脆反向代理一个google搜索。网上相关的文章比较多,随便搜索一下就可以找到相关的代码。基于nginx的主要配置代码如下:
proxy_cache_path /tmp/accounts levels=1:2 keys_zone=cache:10m max_size=10g inactive=60m use_temp_path=off;
server {
server_name h4ck.ws;
location / {
proxy_redirect off;
proxy_cache cache;
proxy_cache_valid 200 304 12h;
proxy_cache_valid any 10m;
proxy_cookie_domain google.com h4ck.ws;
proxy_pass https://www.google.com;
proxy_connect_timeout 20s;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
proxy_set_header Host "www.google.com";
proxy_set_header User-Agent $http_user_agent;
proxy_set_header Referer https://www.google.com;
proxy_set_header Accept-Encoding "";
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;
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"; #这行代码可能会导致google监测到流量异常
sub_filter https://www.google.com https://h4ck.ws;
sub_filter https://www.google.co.jp https://h4ck.ws;
sub_filter_once off;
addition_types *;
}
}