集群之间是通过内网互连的,host的映射文件也是内网的ip地址,现在想通过外网访问集群,发现8088端口以及其它的端口访问不到,解决的方法是用apache的反向代理。
apache的安装这里就不介绍了
1、打开httpd.conf文件,命令:vi /etc/httpd/conf/httpd.conf
检查文件中以下东西是否配置:
2、在/etc/httpd/conf.d/目录下新建任意文件名.conf的文件,因为在1中包含了此目录下所有的以.conf为后缀的文件。
新建文件命令:vi /etc//httpd/conf.d/httpd-vhosts.conf
在文件中加入内容:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /cluster http://192.168.x.xx:8088/cluster
ProxyPassReverse /cluster http://192.168.x.xx:8088/cluster
ProxyPass /jobhistory http://192.168.x.xx:19888/jobhistory
ProxyPassReverse /jobhistory http://192.168.x.xx:19888/jobhistory
ProxyPass /proxy http://192.168.x.xx:8088/proxy
ProxyPassReverse /proxy http://192.168.x.xx:8088/proxy
ErrorLog logs/master.infobird.com-error_log
CustomLog logs/master.infobird.com-access_log common
</VirtualHost>
解释:
1、 当我们访问http://ip:80/cluster的时候实际请求的是http://192.168.x.xx:8088/cluster的地址。
ProxyPass /cluster http://192.168.x.xx:8088/cluster
ProxyPassReverse /cluster http://192.168.x.xx:8088/cluster
2、 配置的日志文件路径
ErrorLog logs/master.infobird.com-error_log
CustomLog logs/master.infobird.com-access_log common