本文标签: nginx
nginx的反向代理,google一直都是不容易打开的,如果你有一台位于国外的vps或者服务器,就可以轻松解决这个问题,这次的主角是nginx,nginx的反向代理现在已经发展很强大了,很多时候拿他来做负载均衡,当然这次只聊聊他的反向代理网站,有人也拿它来做小偷程序。
本次会用到一个nginx的模块,如果没有安装请到官方网站:
https://github.com/yaoweibin/ngx_http_substitutions_filter_module
里面有详细的安装说明,需要重新编译一下nginx。
下面贴一下nginx的配置,假如我们要绑定的域名是www.abc.com,google的地址为www.abc.com/google/
配置如下:
1 2 3 4 5 6 7 8 9 10 |
location /google { proxy_set_header Accept-Encoding ""; proxy_redirect http://www.google.com/ http://www.abc.com/google/; proxy_pass http://www.google.com/; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; subs_filter 'www.google.com' 'www.abc.com/google'; subs_filter 'href="/' 'href="http://www.abc.com/google/'; subs_filter '<form action="/' '<form action="http://www.abc.com/google/'; } |
重新启动nginx,访问www.abc.com/google/ 即可转向google
再贴一个twitter的:
1 2 3 4 5 6 7 8 9 10 11 12 |
location /twitter { proxy_set_header Accept-Encoding ""; proxy_redirect https://mobile.twitter.com/ https://www.abc.com/twitter/; proxy_pass https://mobile.twitter.com/; subs_filter mobile.twitter.com www.abc.com/twitter; subs_filter 'href="/' 'href="https://www.abc.com/twitter/'; subs_filter '<form action="/' '<form action="https://www.abc.com/twitter/'; subs_filter 't.co' 'www.abc.com/t.co'; } location /t.co { proxy_pass http://t.co/; } |
这个需要打开ssl功能,也就是https访问,这个不难,我之前也介绍过,怎么拿到浏览器能够认证的免费ssl证书。
声明: 本文由( liva )原创编译,转载请保留链接: nginx 反向代理 google
- 上一篇:免费的.tk顶级域名注册教程
- 下一篇:linux路由表的优先级
nginx 反向代理 google:等您坐沙发呢!
发表评论
