通过nginx实现内网hadoop、hbase集群对外访问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/
git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
wget http://nginx.org/download/nginx-1.4.2.tar.gz
./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/
makemake install
#替换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 jtserver { 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 nnserver { 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;}