---
title: "apache路由配置jboss"
author: "ylsuccess"
date: "2010-12-23T17:57:31Z"
tags: ["Apache", "JBoss", "JavaScript", "Microsoft", "Socket"]
categories: ["编程语言"]
slug: "apache-jboss"
draft: false
lastmod: "2010-12-23T17:57:31Z"
id: 850478
url: "https://ylsuccess.iteye.com/blog/850478"
---

\[code="java"] Apache路由配置多台JBoss服务器，以下配置按两台JBoss服务器为例。 a) 修改/opt/aspire/product/mid/apache/conf/httpd.conf 在文档中找到Listen 80，修改此端口。并在此行下面添加如下内容： ##################################################################### mid config from here {{ Timeout 300 KeepAlive On MaxKeepAliveRequests 1000 KeepAliveTimeout 60 #LoadModule encoding\_module modules/mod\_encoding.so # #Header add MS-Author-Via "DAV" # # # EncodingEngine on # NormalizeUsername on # SetServerEncoding GBK # DefaultClientEncoding UTF-8 GBK GB2312 # AddClientEncoding "(Microsoft .* DAV $)" UTF-8 GBK GB2312 # AddClientEncoding "Microsoft .* DAV" UTF-8 GBK GB2312 # AddClientEncoding "Microsoft-WebDAV\*" UTF-8 GBK GB2312 # LoadModule fileiri\_module modules/mod\_fileiri.so FileIRI On FilenameCharset GB2312 LoadModule proxy\_module modules/mod\_proxy.so LoadModule proxy\_connect\_module modules/mod\_proxy\_connect.so LoadModule proxy\_ftp\_module modules/mod\_proxy\_ftp.so LoadModule proxy\_http\_module modules/mod\_proxy\_http.so LoadModule proxy\_balancer\_module modules/mod\_proxy\_balancer.so LoadModule proxy\_ajp\_module modules/mod\_proxy\_ajp.so #turning ProxyRequests on and allowing proxying from all may allow #spammers to use your proxy to send email. ProxyRequests Off #Do not proxy balancer-manager #ProxyPass /balancer-manager ! #下载应用地址的配置，只能配置一台子节点机器的地址 ProxyPass /middls http://10.1.4.52:8095/middls ProxyPassReverse /middls http://10.1.4.52:8095/middls #JSESSIONID|BALANCEID ProxyPass / balancer://mycluster/ stickysession=JSESSIONID nofailover=On ProxyPassReverse / balancer://mycluster/ #子节点机器一IP、Port； #route对应子节点机器一jboss的配置 BalancerMember http://10.1.4.52:8095 route=server1 #子节点机器二IP、Port； #route对应子节点机器二jboss的配置 BalancerMember http://10.1.5.50:8095 route=server2 SetEnv force-proxy-request-1.0 1 SetEnv proxy-nokeepalive 1 #AddDefaultCharset off Order deny,allow #Deny from all #Allow from .example.com Allow from all # Enable/disable the handling of HTTP/1.1 "Via:" headers. # ("Full" adds the server version; "Block" removes all outgoing Via: headers) # Set to one of: Off | On | Full | Block # ProxyVia On #AddOutputFilterByType DEFLATE text/html text/plain text/xml application/json text/css application/x-javascript application/javascript include conf/mod\_jk.conf SetHandler balancer-manager Order Deny,Allow Deny from all #Allow from all # mid config end here }} #################################################################### b) 修改/opt/aspire/product/mid/apache/conf/httpd.conf找到 ServerName localhost:8090 改为 ServerName 域名：端口 c) 修改/opt/aspire/product/mid/apache/conf/httpd.conf找到 ErrorLog "logs/error\_log" 改为 #ErrorLog "logs/error\_log" ErrorLog "|/opt/aspire/product/mid/apache//bin/rotatelogs -l /opt/aspire/product/mid/apache/logs/error-%Y-%W.log 1024M" LogFormat "%h %l %u %t \\"%r\\" %&gt;s %b " common 改为 #LogFormat "%h %l %u %t \\"%r\\" %&gt;s %b " common LogFormat "%h --&gt; \[%v | %A] %l %u %t \\"%r\\" %&gt;s %b" common CustomLog "logs/access\_log" common 改为 #CustomLog "logs/access\_log" common CustomLog "|/opt/aspire/product/mid/apache/bin/rotatelogs -l /opt/aspire/product/mid/apache/logs/access-%Y-%W.log 1024M" common d) 修改/opt/aspire/product/mid/apache/conf/httpd.conf找到 # Server-pool management (MPM specific) #Include conf/extra/httpd-mpm.conf 改为 Include conf/extra/httpd-mpm.conf e) 修改/opt/aspire/product/mid/apache/conf/ workers.properties worker.list=server1,server2,balanceworker,jkstatus worker.maintain=60 worker.server1.type=ajp13 #子节点机器IP worker.server1.host=10.1.4.52 #子节点机器Port worker.server1.port=8095 worker.server1.lbfactor=1 worker.server1.socket\_keepalive=False worker.server1.socket\_timeout=0 worker.server2.type=ajp13 #子节点机器IP worker.server2.host=10.1.5.50 #子节点机器Port worker.server2.port=8095 worker.server2.lbfactor=1 worker.server2.socket\_keepalive=False worker.server2.socket\_timeout=0 worker.balanceworker.type=lb worker.balanceworker.balance\_workers=server1,server2 worker.balanceworker.sticky\_session=True worker.balanceworker.sticky\_session\_force=False worker.balanceworker.method=Request worker.jkstatus.type=status \[/code]