Last active
August 29, 2015 14:08
-
-
Save shuxiang/759877655e525ae4be15 to your computer and use it in GitHub Desktop.
proxy of google
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/nginx/sites-enabled/google | |
server { | |
listen 443 default ssl; | |
listen [::]:443; | |
#listen 80; | |
server_name yourhostname; | |
##1,设置反向代理的域名 | |
ssl on; | |
ssl_certificate /home/sx/googleca.crt; | |
ssl_certificate_key /home/sx/nopassgoogle.key; | |
location / { | |
proxy_redirect off; | |
proxy_pass https://www.google.com.hk; | |
proxy_set_header X-Real-IP $remote_addr; | |
# not forward | |
proxy_set_header Host yourhostname; | |
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
# not forward | |
proxy_set_header X-Forwarded-For $remote_addr; | |
proxy_set_header Accept-Encoding ""; | |
#2,如果没有此项,当通过反向代理访问时会被重定向到google的站点,而不能通过反向代理访问 | |
proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.49 S | |
afari/537.36"; | |
#3,可选,可以通过此项设置google打开的默认界面风格,此处呈现为平板的风格,如果不设置,google会自动根据浏览器判 | |
proxy_set_header Accept-Language "zh-CN"; | |
#4,可选,设置界面呈现的语言,如果不设置,google会自动根据浏览器判断 | |
proxy_set_header Cookie "PREF=ID=xxxxxx:U=yyyyy:FF=0:LD=zh-CN:NW=1:CR=2:TM=zzzz:LM=mmmmm:GM=1:SG=1:S=-nnnnn"; | |
#5,可选,设置cookie处理个性化设置,重点为:NW=1表示结果在新窗口中打开,LD=zh-CN表示语言为简体中文,此项将覆盖#4中的设置。( | |
此处某些数据已编辑处理) | |
#sub_filter www.google.com.hk yourhostname; | |
sub_filter www.google.com yourhostname; | |
#6,可选,将页面中的 www.google.com 替换为你的hostname,否则点击某些链接会跳回到google官方。 | |
sub_filter_once off; | |
} | |
} | |
# create crt and key file | |
# key | |
openssl genrsa -des3 -out google.key 2048 | |
# no passwrod key | |
openssl rsa -in google.key -out nopassgoogle.key | |
# crt | |
openssl req -new -x509 -key nopassgoogle.key -out googleca.crt -days 3650 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment