通过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,其主页: 
Java代码   收藏代码
  1. http://code.google.com/p/substitutions4nginx/  


整个实现步骤为: 
1. 下载nginx_substitutions_filter并解压: 
根据官方的建议: 
Java代码   收藏代码
  1. git clone git://github.com/yaoweibin/ngx_http_substitutions_filter_module.git  


2. 下载nginx稳定版并解压: 
Java代码   收藏代码
  1. wget http://nginx.org/download/nginx-1.4.2.tar.gz  


3. 编译安装 
根据自己需要选择要适应的模块,并且指定substitutions4nginx模块的路径 
Java代码   收藏代码
  1. ./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/  

Java代码   收藏代码
  1. make  
  2. make install  

4. 配置nginx.conf 
Java代码   收藏代码
  1. #替换hbase  
  2.  server {  
  3.         listen       8000;        
  4.   
  5.         location / {  
  6.         proxy_pass http://master;  
  7.             subs_filter_types text/html text/css text/xml;  
  8.         subs_filter hd1:60030 192.168.1.25:8000/hd11;  
  9.         subs_filter hd2:60030 192.168.1.25:8000/hd22;  
  10.         }  
  11.   
  12.   
  13.     location /hd11/ {  
  14.             proxy_pass http://192.168.1.25:60030/rs-status;  
  15.         }  
  16.     location /hd22/ {  
  17.             proxy_pass http://192.168.1.30:60030/rs-status;  
  18.         }  
  19.   
  20.     }  
  21.   
  22.   
  23. #替换hadoop jt  
  24. server {  
  25.         listen       8001;  
  26.   
  27.         location / {  
  28.             proxy_pass http://master2;  
  29.             subs_filter_types text/html text/css text/xml;  
  30.             subs_filter hd1:50060 192.168.1.25:8001/hd11;  
  31.             subs_filter hd2:50060 192.168.1.25:8001/hd22;  
  32.         }  
  33.   
  34.   
  35.         location /hd11/ {  
  36.             proxy_pass http://192.168.1.25:50060/tasktracker.jsp;  
  37.         }  
  38.         location /hd22/ {  
  39.             proxy_pass http://192.168.1.30:50060/tasktracker.jsp;  
  40.         }  
  41.   
  42.     }  
  43.   
  44. #替换hadoop nn  
  45. server {  
  46.         listen       8002;  
  47.   
  48.         location / {  
  49.             proxy_pass http://master3;  
  50.             subs_filter_types text/html text/css text/xml;  
  51.             subs_filter hd1:50075 192.168.1.25:8002/hd11;  
  52.             subs_filter hd2:50075 192.168.1.25:8002/hd22;  
  53.         }  
  54.   
  55.   
  56.         location /hd11/ {  
  57.             proxy_pass http://192.168.1.25:50075/;  
  58.         }  
  59.         location /hd22/ {  
  60.             proxy_pass http://192.168.1.30:50075/;  
  61.         }  
  62.   
  63.     }  
  64.   
  65. upstream  master {  
  66.      server 192.168.1.30:60010;  
  67. }  
  68.   
  69. upstream  master2 {  
  70.          server 192.168.1.25:50030;  
  71. }  
  72.   
  73. upstream  master3 {  
  74.          server 192.168.1.25:50070;  
  75. }  


重启ng服务让配置生效。 

这样就可以通过统一ng入口访问内网集群了,后面如果有需要添加的修改nginx.conf就行。 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值