마니의 공부방/개발 꼼수

두개의 도메인 + 하나의 아파치 + 각각 도메인별 두개의 톰켓

회사에서 프로젝트를 진행중, 하나의 서버에 서비스가 두개 올라가야 하는 일이 생겼다.
IDC정책상 외부 유입 포트는 하나밖에 오픈이 안된다.
따라서, 아래와 같은 구조로 환경세팅을 해야하는 경우가 되었다.

 두개의 도메인 + 하나의 아파치 + 각각 도메인별로 두개의 톰캣

이제 설정을 해보자.

1. 아파치의 conf/httpd.conf => 빨간부분을 참고로 설정하면된다

 ... 중략 ...

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#

#LoadModule jk_module modules/mod_jk.so
Include conf.d/*.conf


### Section 3: Virtual Hosts
#
# VirtualHost: 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.0/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.

#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
NameVirtualHost 121.125.xx.xx

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot /www/docs/dummy-host.example.com
#    ServerName dummy-host.example.com
#    ServerName dev.quickchannel.kr
#    DocumentRoot /usr/local/tomcat-5.5.23/webapps/w
#    ServerAlias /wap/ /w/
#    ErrorLog logs/dummy-host.example.com-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
#Alias  /wap/   "/w/"

#JkMount /servlet/* worker1
#JkMount /jsp-examples/* worker1
#JkMount /servlets-examples* worker1
#JkMount /*.jsp worker1
#JkMount /*.html worker1
#JkMount /*.do worker1
#</VirtualHost>

<VirtualHost 121.125.xx.xx:80>                        <= 서버 아이피
ServerName dev.xx.kr                                   <= 사용도메인1
<Directory /usr/local/httpd/htdocs/xx>           <= 톰캣 컨텍스트루트
Order allow,deny
Allow from all
</Directory>
JkMount /*.do dev1
JkMount /*.jsp dev1
</VirtualHost>

<VirtualHost 121.125.73.35:80>
ServerName 
www.xxx.kr                           
<Directory /usr/local/httpd/htdocs/xxx>
Order allow,deny
Allow from all
</Directory>
JkMount /*.do dev2
JkMount /*.jsp dev2
</VirtualHost>


2. conf/conf.d/tomcat.conf : 위에서 "Include conf.d/*.conf"로 include한 파일

 LoadModule jk_module modules/mod_jk.so

JkWorkersFile /usr/local/httpd/conf/worker.properties
JkLogFile /usr/local/httpd/logs/mod_jk.log
JkLogLevel error
JkLogStampFormat "[%a %b %d %H:%M:%S %Y]"
JkRequestLogFormat "%w %V %T"


3. conf/worker.properties

worker.list=dev1,dev2

worker.dev1.host=dev.quickchannel.kr
worker.dev1.port=8009
worker.dev1.lbfactor=1
worker.dev1.type=ajp13

worker.dev2.host=www.quickchannel.kr
worker.dev2.port=8010
worker.dev2.lbfactor=1
worker.dev2.type=ajp13


4. dev1 tomcat의 server.xml

  <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
    <!-- Note : To disable connection timeouts, set connectionTimeout value
     to 0 -->
        
        <!-- Note : To use gzip compression you could set the following properties :
        
                           compression="on" 
                           compressionMinSize="2048" 
                           noCompressionUserAgents="gozilla, traviata" 
                           compressableMimeType="text/html,text/xml"
        -->
    
    <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
    <!--
    <Connector port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->
    
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

5.  dev2 tomcat의 server.xml

 <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="8081" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
    <!-- Note : To disable connection timeouts, set connectionTimeout value
     to 0 -->
        
        <!-- Note : To use gzip compression you could set the following properties :
        
                           compression="on" 
                           compressionMinSize="2048" 
                           noCompressionUserAgents="gozilla, traviata" 
                           compressableMimeType="text/html,text/xml"
        -->
    
    <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
    <!--
    <Connector port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->
    
    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8010
               enableLookups="false" redirectPort="8444" protocol="AJP/1.3" />

'마니의 공부방 > 개발 꼼수' 카테고리의 다른 글

ie innerhtml  (0) 2011.07.07
구글 크롬 단축키  (0) 2011.03.17
[excel] 한영 자동변환 기능 끄기  (0) 2011.03.16
[jsp] 파라미터 한글깨짐현상  (0) 2011.03.10
jquery 폼 전체요소 활성화 컨트롤  (0) 2011.03.02