nginx反向代克隆网站

我们可以通过Nginx的反向代理,来实现山寨或克隆一个网站。

比做小偷站实现起来更简单,因为不用任何网站程序,只需配置Nginx的反向代理即可。

  1. upstream www_cqclub_com {
  2.     server  115.238.101.200:80;
  3. }
  4. server{
  5.     listen 80;
  6.     server_name www.cqclub.com;
  7.     proxy_set_header Host www.22.cn;
  8.     proxy_set_header x-forwarded-for  $remote_addr;
  9.     location /{
  10.         proxy_pass http://www_cqclub_com;
  11.     }
  12. }

并且可以使用第三方模块HttpSubModule进行关键词替换,可以将对方网站的域名,广告等替换成自己的。

插件地址: http://wiki.nginx.org/HttpSubsModule

  1. location / {
  2.     subs_filter_types text/html text/css text/xml;
  3.     subs_filter st(\d*).example.com $1.example.com ir;
  4.     subs_filter a.example.com s.example.com;
  5. }

当然我们也可以在nginx中开启缓存,这样就不需要每次都向源网站发起请求了。

发表评论

邮箱地址不会被公开。 必填项已用*标注