有时候没上代理方便查资料,直接开个谷歌反代服务吧,配置过程如下

安装nginx略

编辑nginx配置文件

vim /usr/local/nginx/conf/nginx.conf
在http部分加入以下内容

proxy_connect_timeout 5;
proxy_read_timeout 60;
proxy_send_timeout 5;
proxy_buffer_size 16k;
proxy_buffers 4 64k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_temp_path /tmp/cache/temp;
proxy_cache_path /tmp/cache/path levels=1:2 keys_zone=cache_one:5m inactive=7d max_size=1g;

保存然后编辑虚拟机配置文件

vim /usr/local/nginx/conf/vhost/g.yh.gs.conf
将server段替换为下面的内容

server
{
        listen 80;
        server_name google.cker.in;

        location / {
                proxy_redirect off; #http://www.google.com/ /;

                proxy_set_header HOST 'www.google.com';
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_cookie_domain google.com google.cker.in;
                proxy_pass https://74.125.23.139;
                proxy_set_header Accept-Encoding "";
                proxy_set_header User-Agent $http_user_agent;
                proxy_set_header Accept-Language "en-US";
                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.cker.in;
                sub_filter_once off;
                auth_basic    "USER: cker PASS: cker";
                auth_basic_user_file    auth_google.cker.in;

        }
}

 

其中74.125.23.139是指google.com的ip,可以到网上找找,或在国外VPS上解析一下

dig google.com @8.8.8.8

; <<>> DiG 9.8.3-P1 <<>> google.com @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 21253
;; flags: qr rd ra; QUERY: 1, ANSWER: 6, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;google.com.            IN    A

;; ANSWER SECTION:
google.com.        299    IN    A    74.125.23.139
google.com.        299    IN    A    74.125.23.102
google.com.        299    IN    A    74.125.23.101
google.com.        299    IN    A    74.125.23.100
google.com.        299    IN    A    74.125.23.113
google.com.        299    IN    A    74.125.23.138

生成401认证密文

➜  ~ htpasswd -dmbc auth_google.cker.in cker cker
Adding password for user cker
➜  ~ cat cker             
cker:***********

 

保存后测试下配置文件是否有问题

/usr/local/nginx/sbin/nginx –t

如果出现下面的两句说明配置文件一切正常
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

确认没有问题后平滑重启nginx

kill -HUP `cat /usr/local/nginx/logs/nginx.pid`

访问效果

image

image

源链接

Hacking more

...