1
danbao 2014-07-02 09:54:39 +08:00 1
server {
listen 443 default ssl; listen [::]:443; server_name google.hahahahhahahahha.com; #1,设置反向代理的域名 ssl on; ssl_certificate /cert/hahahahhahahahha.cer; ssl_certificate_key /cert/hahahahhahahahha.pem; location / { proxy_redirect off; proxy_pass https://www.google.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 ""; #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 Safari/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 g.linzhen.net; #6,可选,将页面中的 www.google.com 替换为g.linzhen.net,否则点击某些链接会跳回到google官方。 sub_filter_once off; } } 这是我的配置,带HTTPS的 |
2
iCodex 2014-07-02 09:59:46 +08:00
cat >/usr/local/nginx/conf/_proxy.inc <<EOF
proxy_connect_timeout 600s; proxy_send_timeout 600s; proxy_read_timeout 600s; proxy_buffer_size 64k; proxy_buffers 32 32k; proxy_busy_buffers_size 128k; proxy_cache_revalidate on; proxy_redirect off; proxy_hide_header Vary; proxy_set_header Accept-Encoding ''; proxy_set_header Host \$proxy_host; proxy_set_header Referer \$proxy_host; proxy_set_header Cookie \$http_cookie; proxy_pass_header Set-Cookie; client_max_body_size 100m; client_body_buffer_size 128k; add_header X-Via "Proxy"; EOF server { resolver 8.8.8.8; listen 80; server_name gg.org; location / { subs_filter 'www.google.com' '$host'; proxy_pass http://www.google.com; include _proxy.inc; } } |
3
akira 2014-07-02 10:11:08 +08:00
是自己编译的nginx么, sub_filter装了么
|
5
ultimate010 2014-07-04 11:36:22 +08:00
@danbao 给力,使用了.
|
6
sadan9 OP subs_filter 不一定好用啊= =,有的时候会碰到google.co.jp google.com.sg之类的……
|
7
Livid MOD proxy_set_header Host www.google.com.hk;
|
8
sadan9 OP server{
listen 443; ssl on; server_name s.galdb.net; ssl_certificate /data/crt/s.galdb.net.crt; ssl_certificate_key /data/crt/s.galdb.net.key; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Accept-Encoding ""; proxy_pass http://www.google.com.hk; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Accept-Language "zh-CN"; sub_filter www.google.com.hk s.galdb.net; sub_filter_once off; proxy_redirect off; proxy_set_header Host www.google.com.hk; } } 用这个配置还是会被重新定向到www.google.com.hk = = |
9
feather12315 2015-09-17 00:29:43 +08:00
|