我的nginx服务器在香港,直接在nginx配置文件中添加一下内容就可以
proxy_cache_path conf/cache/one levels=1:2 keys_zone=one:10m max_size=10g; proxy_cache_key "$host$request_uri"; server { listen 80; server_name g.example.com; access_log /var/log/nginx/access.log; rewrite ^(.*) https://g.example.com$1 permanent; } upstream google { server 173.194.127.212; server 173.194.127.208; server 173.194.127.209; server 173.194.127.210; server 173.194.127.211; } server { listen 443; server_name g.example.com; access_log /var/log/nginx/access.log; ssl on; ssl_certificate ssl/g.crt; ssl_certificate_key ssl/g.key; location / { proxy_cache one; proxy_cache_valid 200 302 1h; proxy_cache_valid 404 1m; proxy_redirect off; proxy_pass https://www.google.com.hk/; proxy_redirect https://www.google.com.hk/ /; proxy_cookie_domain www.google.com g.example.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 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"; subs_filter www.google.com g.example.com; } }
最后访问http://g.example.com就可以哦!!!快来试试吧!!!
时间: 2024-12-21 11:17:18