Nginx配置hbaseweb转发

目标

为了公司集群的安全考虑,hadoop和hbase的web访问只能供有限的人访问 而要实现内网机器给外网访问,要解决的问题是:  1.hadoop、hbase页面上的url替换成外网能访问的url  2.通过有限的端口、外网ip对外提供整集群访问  下面就通过nginx反向代理的方式实现

步骤

整个实现步骤为:

### 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.8.0.tar.gz  

tar -zxf nginx-1.8.0.tar.gz 

编译安装

cd nginx-1.8.0

4../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=/data/ngx_http_substitutions_filter_module/ 

#######  add-module后面是 ngx_http_substitutions_filter_module的路径

报错:the HTTP rewrite module requires the PCRE library.

yum -y install pcre-devel

5. make  

6. make install 

7. 配置cd /usr/local/nginx/conf目录下的nginx.conf

server {

        listen      80;

        location / {

                proxy_pass http://node2:16010/;

                subs_filter_types text/css text/xml;

                subs_filter node2:16030 node2/hd11;

                subs_filter node3:16030 node2/hd22;

            #root  html;

            #index  index.html index.htm;

        }

#hbase 默认的链接是加rs-status的,避免需要手动去掉,添加这个

        location /hd11/rs-status {

            proxy_pass http://node2:16030/rs-status;

        }

#storeFile.jsp界面显示不出来,添加

        location /hd11/storeFile.jsp {

            proxy_pass http://node2:16030/storeFile.jsp;

        }

#region.jsp界面显示不出来,添加

        location /hd11/region.jsp {

            proxy_pass http://node2:16030/region.jsp;

        }

        location /hd22/region.jsp {

            proxy_pass http://node3:16030/region.jsp;

        }

        location /hd22/storeFile.jsp {

            proxy_pass http://node3:16030/storeFile.jsp;

        }

        location /hd22/rs-status {

            proxy_pass http://node3:16030/rs-status;

        }

### 本次的集群是node2和node3两个节点,hbase为1.2.6

8. 配置好之后cd /usr/local/nginx/sbin/目录下

./nginx启动

Ps -ef | grep nginx  查看启动的nginx进程

root    17369    1  0 14:21 ?        00:00:00 nginx: master process ./nginx

nobody  17370 17369  0 14:21 ?        00:00:00 nginx: worker process

root    19090 16107  0 15:48 pts/0    00:00:00 grep nginx

输入node2即可查看hbase界面(因为nginx配置的是80端口,页面node2打开默认也是80端口,所以并不需要输入端口号) 



Regionserver节点地址 

9. 接下来,配置iptables,限制原来的16010端口

iptables -A INPUT -p tcp --dport 16010 -j DROP

禁止访问16010端口

iptables -I INPUT -s node2 -ptcp --dport 16010 -j ACCEPT

iptables -I INPUT -s node3 -ptcp --dport 16010 -j ACCEPT

允许hbase集群的两个节点访问16010端口

service iptables save

service iptables restart

重启结束

直接通过node2:16010访问不成功


通过80端口依旧ok


Nginx通过80端口反向代理连接hbaseweb成功

参考文章:http://blackwing.iteye.com/blog/1949154

你可能感兴趣的:(Nginx配置hbaseweb转发)