## 환경
# Linux 7
# Tomcat 8
# Java 1.8
# Apache 2.2
##Tomcat Server.xml 설정
## 경로 : /usr/local/src/tomcat/conf/server.xml
## Port 설정
# 1. shutdown Port
# 2. connect Port
# 3. ajp Port (세션 공유를 위해 필요) 기본 8009 (방화벽 열려 있음)
# [ajp Port 다른 포트 사용시 SELinux port 개방]
# SELinux Port 명령어 : ./semanage port -a -t http_port_t -p tcp [추가할 포트]
# 방화벽 Port 명령어 :
#[Linux 7] firewall-cmd --permanent --zone=public --add-port=45564/tcp
#[Linux 7] firewall-cmd --permanent --zone=public --add-port=45564/udp
#[Linux 7] firewall-cmd --reload // 변경
#[Linux 7] firewall-cmd --list-ports // 방화벽 개방 포트 리스트
#[Linux 7] firewall-cmd --zone=public --list-service // 방화벽 개방 서비스 리스트
# 4. Apach 설치가 되어있음 서비스 및 Port 개방이 되어있음
# HTTP Port (80)
# HTTPS Port (443)
# 5. 톰캣 세션 클러스터 Port 개방 명령어
# firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source
# address="xx.xx.xx.xx" // 현재 서버 IP 주소
# port protocol="tcp"
# port="4001" accept" // 클러스터 Port
<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1">
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="6">
<Manager className="org.apache.catalina.ha.session.DeltaManager" expireSessionsOnShutdown="false" notifyListenersOnReplication="true"/>
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4" //
port="45564" //공유 포트 udp port 로 개방
frequency="500"
dropTime="3000"/>
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="xx.xx.xx.x" // 현재 서버 IP 주소
port="4001" // 특정 port 각 서버별 달라야함 (4001 ~ 4010) 보통 처리
autoBind="100"
selectorTimeout="5000"
maxThreads="6"/>
<Sender className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport className="org.apache.catalina.tribes.transport.nio.PooledParallelSender"/>
</Sender>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector"/>
<Interceptor className="org.apache.catalina.tribes.group.interceptors.MessageDispatchInterceptor"/>
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/>
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve"/>
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/"
deployDir="/tmp/war-deploy/"
watchDir="/tmp/war-listen/"
watchEnabled="false"/>
<ClusterListener className="org.apache.catalina.ha.session.ClusterSessionListener"/>
</Cluster>
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="false">
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
<Context path="/" crossContext="true" docBase="/usr/local/src/kpta_client/webapps/ROOT" reloadable="false" sessionCookieDomain=".xxxx.co.kr" // 도메인 설정 .xxxx.co.kr
>
</Context>
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
## HTTP 설정
# 경로 : /etc/httpd/conf/
# 1. httpd.conf
# httpd.conf backup
# 복사 명령어 : cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.original
## LoadModule foo_module modules/mod_foo.so 주석 밑에 붙여 넣기
# Include conf.modules.d/*.conf // 기본으로 작성 되어있음
# LoadModule jk_module modules/mod_jk.so // 추가 mod_jk
# Include conf/mod_jk.conf // 추가 mod_jk
# Include conf/extra/httpd-vhosts.conf // 추가 vhosts
# 2. mod_jk.conf
# 우선 mod_jk.so 파일 /etc/httpd/modules 경로에 파일 추가
# conf 경로에 vi mod_jk.conf 파일 추가
<IfModule mod_jk.c>
JkWorkersFile conf/workers.properties
JkLogFile /etc/httpd/logs/mod_jk.log
JkLogLevel info
# JkAutoAlias "/usr/local/src/tomcat/webapps"
JkMount /* ajp13
JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /examples/*.jsp ajp13
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories
JkRequestLogFormat "%w %V %T"
JkMountFile conf/uri.properties
</IfModule mod_jk.c>
# 3. uri.properties
# conf 경로에 uri.properties 파일 추가
/*=worker1
# 4. workers.propertis
# conf 경로에 workers.properties 파일 추가
worker.list=lb1, jkstatus
#현재 서버 정보
#ajp Port/ host 설정
worker.worker1.port=8009
worker.worker1.host=localhost
worker.worker1.type=ajp13
worker.worker1.lbfactor=1
#다른 서버 정보
worker.worker3.port=8009
worker.worker3.host=xx.xx.xx.xx
worker.worker3.type=ajp13
worker.worker3.lbfactor=1
worker.lb1.type=lb
worker.lb1.balance_workers=worker1,worker3
## status worker
worker.jkstatus.type=status
# 5. extra/httpd-vhosts.conf
# conf/extra 경로 httpd-vhosts.conf 파일 생성
#Virtual Hosts
#
# Required modules: mod_log_config
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# 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 block.
#
#NameVirtualHost *:80
# 현재 서버 tomcat
<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/src/tomcat/webapps"
ServerName www.xxx.co.kr
ServerAlias www.xxx.co.kr
ErrorLog /etc/httpd/logs/centerhost.error_logs
# CustomLog "logs/dummy-host.example.com-access_log" common
JkMount /* lb1
<Directory "/usr/local/src/tomcat/webapps">
AllowOverride None
Require all granted
</VirtualHost *:80>
# 다른 서버 tomcat
<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/src/tomcat/webapps"
ServerName xxx.co.kr
ServerAlias xxx.co.kr
ErrorLog /etc/httpd/logs/centerhost.error_logs
# CustomLog "logs/dummy-host.example.com-access_log" common
JkMount /* lb1
<Directory "/usr/local/src/tomcat/webapps">
AllowOverride None
Require all granted
</VirtualHost *:80>