Apache+Jboss负载均衡加域名转发

Apache2.2+jboss4.2.3

先说负载均衡

 

httpd.conf 的Listen是8080

 

1,修改E:/jboss-4.2.3.GA/server/default/deploy/jboss-web.deployer

server.xml

这个是其中一台服务器修改后的结果啊

<Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
         emptySessionPath="true" enableLookups="false" redirectPort="8443" />

      <Engine name="jboss.web" defaultHost="localhost"  jvmRoute="node1">

 

注意红字部分

 

2,httpd.conf最后一行加上

    Include conf/mod-jk.conf

 

3,mod-jk.conf文件内容

# Load mod_jk module. Specify the filename
# of the mod_jk lib you’ve downloaded and
# installed in the previous section
LoadModule jk_module modules/mod_jk.so
# Where to find workers.properties
JkWorkersFile conf/workers.properties
# Where to put jk logs
JkLogFile logs/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel info
# Select the log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# JkOptions indicate to send SSL KEY SIZE,
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"
JkMount /* loadbalancer

 

4,workers.properties文件内容

 # 定义request所要转发到的节点                             
worker.list=loadbalancer,status                         
# 定义节点 Node1                                         
worker.node1.port=8009                                  
worker.node1.host=localhost                           
worker.node1.type=ajp13                                 
worker.node1.lbfactor=1                                 
worker.node1.cachesize=10                               
# 定义节点 Node2                                         
worker.node2.port=8009                                  
worker.node2.host=192.168.0.13                           
worker.node2.type=ajp13                                 
worker.node2.lbfactor=1                                 
worker.node2.cachesize=10                               
# 负载配置                                               
worker.loadbalancer.type=lb                             
worker.loadbalancer.balance_workers=node1,node2        
worker.loadbalancer.sticky_session=0                    
worker.status.type=status 

 

 

5,mod_jk.so文件是从网上下载的mod_jk-1.2.27-httpd-2.2.10.so重命名的

 

这样负载均衡就完了,下面说下域名转发

 

1,httpd.conf最后一行加上 Include conf/extra/httpd-vhosts.conf

 

httpd-vhosts.conf文件内容

 

NameVirtualHost *:8080

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:8080> 
    DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/test1"
    ServerName www.163.com
</VirtualHost>

<VirtualHost *:8080> 
    DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/test2"
    ServerName www.sohu.com
</VirtualHost>

<VirtualHost *:8080>
    # DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/test2"
    ServerName www.sina.com   
    JkMount  /*  loadbalancer
</VirtualHost>

#当为上面两个域名时访问Apache自己目录下的静态文件,当为第三个域名时访问配置的负载均衡

 

 还要补充啊,如何给本地指定域名

 C:/WINDOWS/system32/drivers/etc/

里面的 hosts文件

127.0.0.1       localhost
127.0.0.1       www.163.com
127.0.0.1       www.sina.com
127.0.0.1       www.sohu.com

这样下面三个域名指想的就是自己的机器了

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值