ÃֽŠ°Ô½Ã±Û(OS/WAS)
2018.03.12 / 24:56

¾ÆÆÄÄ¡-ÅèĹ ¿¬µ¿ - apache 2.4.20 tomcat 8.x

ÈÞ°í
Ãßõ ¼ö 201

°ü·Ã ¹®¼­


Å×½ºÆ® ȯ°æ

  • apache 2.4.20
  • tomcat 8.x


Á¶°Ç:

  • ¾ÆÆÄÄ¡¿Í ÅèĹÀº ¼³Ä¡µÇ¾î ÀÖ´Ù °¡Á¤
  • µÎ °³ÀÇ È£½ºÆ®¸¦ °¢°¢ÀÇ WAS·Î ±¸µ¿(ÇϳªÀÇ ¾ÆÆÄÄ¡¿¡ ÅèĹ µÑ)


TODO: mod_jk.so ¼³Ä¡¹æ¹ý Ãß°¡

TODO: VirtualHost ¼³Á¤¹æ¹ý Ãß°¡


Apache Tomcat Connectors

¿ì¼± JK ¸ðµâÀÌ ÇÊ¿äÇѵ¥ JK ¸ðµâÀº The Apache Tomcat Connectors¸¦ ÁöĪÇÏ´Â ¸»·Î ¾ÆÆÄÄ¡-ÅèĹ ¿¬µ¿¿¡ ÇÊ¿äÇÑ ¸ðµâÀ̸ç AJP·Î Åë½ÅÇÑ´Ù.

mod_jk.so¸¦ ¾ÆÆÄÄ¡¼³Ä¡°æ·Î/modules ¾Æ·¡¿¡ À§Ä¡½ÃŲ´Ù. mod_jk.so´Â OS¿¡ µû¶ó ÀûÇÕÇÑ ÆÄÀÏÀÌ ´Ù¸£´Ù. ¸®´ª½º ȯ°æÀ̶ó¸é ÄÄÆÄÀÏÀ» Á÷Á¢ ÇØ¾ß ÇÒ ¼öµµ ÀÖ´Ù. ¸¸¾à ¾ÆÆÄÄ¡ ±¸µ¿ Áß 'invalid ELF header' ¿¡·¯°¡ ¹ß»ýÇϸé mod_jk.so°¡ À߸øµÈ °ÍÀÌ´Ù. (ÄÄÆÄÀÏ ¹öÀüÀÌ ´Ù¸£´Ù´øÁö)

JK ¸ðµâ ¼³Ä¡¸¦ ¿Ï·áÇßÀ¸¸é /httpd/conf/httpd.conf¿¡ ´ÙÀ½À» Ãß°¡ÇÑ´Ù:

Listen 80

Include conf.modules.d/*.conf

# ¾Æ·¡¸¦ Ãß°¡
LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info
JkMount /bo/* worker1
JkMount /* worker2

JkMount´Â ¿äûÀ» ó¸®ÇÒ WAS¸¦ ÀǹÌÇϴµ¥ À§ÀÇ °æ¿ì ¿äûµÈ ÁÖ¼ÒÀÇ PATH°¡ /bo/·Î ½ÃÀÛÇϸé worker1¿¡, ±× ¿Ü ¸ðµç ÁÖ¼Ò´Â worker2¿¡ Æ÷¿öµù µÈ´Ù. JkMount ¼³Á¤ÀÌ ¿©·¯°³ ÀÖÀ»¶§´Â »ó´Ü¿¡ ÀÖ´Â °ÍÀÌ ¿ì¼±¼øÀ§°¡ ³ô´Ù.

ÇöÀç±îÁø JkMount·Î ¸í½ÃÇÑ worker1°ú worker2¸¦ ãÀ» ¼ö ¾ø´Ù. µû¶ó¼­ /httpd/conf/workers.properties¸¦ ´ÙÀ½Ã³·³ ÀÛ¼ºÇÑ´Ù:

# HTTPD Web Server and Apache Tomcat(ajp) Connector
# the loadbalancer configuration of the Server
#
# Include workers.properties by conf/extra/httpd-modjk.conf
#
# Define loadbalancer 2 worker node using ajp13
# admin Cluster Group 1 #############################################
#
# configuration template
worker.template.type=ajp13
#worker.template.lbfactor=1
#worker.template.socket_timeout=30
#worker.template.socket_keepalive=true
#worker.template.recovery_options=7
#worker.template.ping_mode=A
#worker.template.ping_timeout=10000
#worker.template.connection_pool_size=25
#worker.template.connection_pool_minsize=25
#worker.template.connection_pool_timeout=60

worker.list=worker1, worker2

worker.worker1.reference=worker.template
worker.worker1.port=8009
worker.worker1.host=localhost

worker.worker2.reference=worker.template
worker.worker2.port=8010
worker.worker2.host=localhost

#worker.wlb.type=lb
#worker.wlb.retries=2
#worker.wlb.method=Session
#worker.wlb.sticky_session=True
#worker.wlb.balance_workers=worker1, worker2

°¢ ÅèĹÀÇ ¼³Ä¡°æ·Î/conf/server.xmlÀÇ ¼³Á¤À» ´ÙÀ½Ã³·³ ¼öÁ¤ÇÑ´Ù:

bo(worker1) server.xml:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
<!-- »ý·« -->
<Context docBase="back-web" path="/bo" reloadable="false"/>

fo(worker2) server.xml:

<Connector port="8010" protocol="AJP/1.3" redirectPort="8443"/>
<!-- »ý·« -->
<Context docBase="front-web" path="/" reloadable="false"/>

¿©±â¼­ docBase´Â ÅèĹÀÇ webapps ¾Æ·¡¿¡ À§Ä¡ÇÑ Æú´õ ȤÀº WARÆÄÀÏÀ» ¸»ÇÑ´Ù.

¾ÆÆÄÄ¡ ±¸µ¿

httpd -k start

ÅèĹ ±¸µ¿

startup.bat  # ȤÀº startup.sh

¿¡·¯ ¾øÀÌ ±¸µ¿¿¡ ¼º°øÇÏ¸é ¾Æ·¡ ÁÖ¼Ò·Î Å×½ºÆ®

http://localhost/bo/
http://localhost


VirtualHost

¾Æ·¡Ã³·³¸¸ Çصµ µ¹¾Æ°¨¤»

LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info

<virtualhost *:80>
    ServerName bo.test.com
    DocumentRoot /home/user1/was/bo/webapps/back-web/
    JkMount /* worker1
</virtualhost>

<virtualhost *:80>
    ServerName fo.test.com
    DocumentRoot /home/user1/was/fo/webapps/front-web/
    JkMount /* worker2
</virtualhost>

hosts ¼³Á¤ÇÏ°í ¾Æ·¡ ÁÖ¼Ò·Î Å×½ºÆ®

http://bo.test.com
http://fo.test.com


Configuring Apache to serve static web application files

If the Tomcat Host appBase (webapps) directory is accessible by the Apache web server, Apache can be configured to serve web application context directory static files instead of passing the request to Tomcat.


Caution: For security reasons it is strongly recommended that JkMount is used to pass all requests to Tomcat by default and JkUnMount is used to explicitly exclude static content to be served by httpd. It should also be noted that content served by httpd will bypass any security constraints defined in the application's web.xml.

Use Apache's Alias directive to map a single web application context directory into Apache's document space for a VirtualHost:


# Static files in the examples webapp are served by apache

Alias /examples /vat/tomcat3/webapps/examples

# All requests go to worker1 by default

JkMount /* worker1

# Serve html, jpg and gif using httpd

JkUnMount /*.html worker1

JkUnMount /*.jpg  worker1

JkUnMount /*.gif  worker1