通过nginx实现内网hadoop集群对外访问web界面

http://blackwing.iteye.com/blog/1949154


不少公司为了安全,hadoop、hbase集群都是不对外开放,只有一台入口机对外,那么当要查看hadoop、hbase集群机器状态等信息时,就没办法了。

而要实现内网机器给外网访问,要解决的问题是:
1.hadoop、hbase页面上的url替换成外网能访问的url
2.通过有限的端口、外网ip对外提供整集群访问
强大的nginx正好能解决这个问题。而nginx要替换返回的页面内容,虽然它自己有模块可以实现,但据了解只能替换一次,而网上比较常用的是第三方的替换模块nginx_substitutions_filter,其主页:
http://code.google.com/p/substitutions4nginx/
整个实现步骤为:
1. 下载nginx_substitutions_filter并解压:
根据官方的建议:
git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
2. 下载nginx稳定版并解压:
wget http://nginx.org/download/nginx-1.4.2.tar.gz
3. 编译安装
根据自己需要选择要适应的模块,并且指定substitutions4nginx模块的路径
./configure --prefix=/usr/local/nginx --pid-path=/usr/local/nginx.pid  --with-http_dav_module --with-http_flv_module --with-http_realip_module --with-http_gzip_static_module --with-http_stub_status_module  --with-debug --add-module=/home/hadoop/nginx/third-party-md/ngx_http_substitutions_filter_module/
make
make install
4. 配置nginx.conf
#替换hbase
server {
        listen       8000;      
        location / {
            proxy_pass http://master;
            subs_filter_types text/html text/css text/xml;
            subs_filter hd1:60030 192.168.1.25:8000/hd11;
            subs_filter hd2:60030 192.168.1.25:8000/hd22;
        }
        location /hd11/ {
            proxy_pass http://192.168.1.25:60030/rs-status;
        }
        location /hd22/ {
            proxy_pass http://192.168.1.30:60030/rs-status;
        }
    }
#替换hadoop jt
server {
        listen       8001;
        location / {
            proxy_pass http://master2;
            subs_filter_types text/html text/css text/xml;
            subs_filter hd1:50060 192.168.1.25:8001/hd11;
            subs_filter hd2:50060 192.168.1.25:8001/hd22;
        }
        location /hd11/ {
            proxy_pass http://192.168.1.25:50060/tasktracker.jsp;
        }
        location /hd22/ {
            proxy_pass http://192.168.1.30:50060/tasktracker.jsp;
        }
    }
#替换hadoop nn
server {
        listen       8002;
        location / {
            proxy_pass http://master3;
            subs_filter_types text/html text/css text/xml;
            subs_filter hd1:50075 192.168.1.25:8002/hd11;
            subs_filter hd2:50075 192.168.1.25:8002/hd22;
        }
        location /hd11/ {
            proxy_pass http://192.168.1.25:50075/;
        }
        location /hd22/ {
            proxy_pass http://192.168.1.30:50075/;
        }
    }
upstream  master {
         server 192.168.1.30:60010;
}
upstream  master2 {
         server 192.168.1.25:50030;
}
upstream  master3 {
         server 192.168.1.25:50070;
}
重启ng服务让配置生效。
这样就可以通过统一ng入口访问内网集群了,后面如果有需要添加的修改nginx.conf就行。
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值