The Jakarta Project The mighty Tomcat - Meow!

mod_jk »ç¿ë¹ý

By Gal Shachor <shachor@il.ibm.com>
Trans By Kenu <heogn@shinbiro.com>

¸ñÂ÷


mod_jk?

mod_jk ´Â ÀÌÀüÀÇ mod_jservÀÇ ´ëÄ¡¿ëÀÔ´Ï´Ù. Tomcat °ú Apache ¸¦ ¿¬µ¿ÇÏ´Â ¾ÆÁÖ »õ·Î¿î Tomcat-Apache plugin ÀÔ´Ï´Ù.


¿Ö mod_jk?

¿©·¯ ÀÌÀ¯:


¿Ö ¾µ±î?

»õ·Ó°í ´Ü¼øÇÑ ¼³Ä¡±â¹ýÀ» ¾Ë ÇÊ¿ä°¡ ÀÖ°ÚÁÒ. ÀÌ ±â¹ýÀ» ¾Ë°ÔµÈ´Ù¸é IIS³ª Netscape °°Àº À¥¼­¹ö¿¡ TomcatÀ» ¿¬µ¿ÇÒ ¶§ ¾ÆÁÖ ½±°Ô ÇÒ ¼ö ÀÖÀ» °ÍÀÔ´Ï´Ù.


Á¤ÀÇ¿Í ¿ë¾î

ÀÌ ¹®¼­¿¡¼­ »ç¿ëµÇ´Â ´Ü¾îµéÀÇ ¶æÀº ´ÙÀ½°ú °°½À´Ï´Ù:

¿ë¾î

ÀǹÌ

Worker process

worker´Â À¥¼­¹ö·ÎºÎÅÍÀǼ­ºí¸´ ¿äûÀ» ó¸®Çϱâ À§ÇØ µ¿ÀÛÇÏ´Â tomcat ÀνºÅϽºÀÔ´Ï´Ù. ´ëºÎºÐ ÇϳªÀÇ worker °¡ ÀÖ½À´Ï´Ù(ÇϳªÀÇ À¯ÀÏÇÑ tomcat process).±×·¯³ª ¶§·Î´Â load ¹ë·±½ÌÀ̳ª site ÆÄƼ¼Å´×À» À§ÇØ ¿©·¯°³ÀÇ worker¸¦ ¶ç¿ì°Ô µË´Ï´Ù. °¢°¢ÀÇ worker ´Â ÀÚ½ÅÀÌ ÀÚ¸®ÀâÀº È£½ºÆ®, ¿­·ÁÀÖ´Â Æ÷Æ®, ¸Þ½ÃÁö ±³È¯¿¡ »ç¿ëµÇ´Â Åë½ÅÇÁ·ÎÅäÄÝ¿¡ ÀÇÇØ À¥¼­¹ö¿¡¼­ ±¸ºÐµÇ¾îÁý´Ï´Ù.

In process worker

Ưº°ÇÑ workerÀÔ´Ï´Ù. ´Ù¸¥ ÇÁ·Î¼¼½º¿¡ »óÁÖÇÏ°íÀÖ´Â Tomcat process ¿Í µ¿ÀÛÇÏ´Â ´ë½Å, À¥¼­¹ö°¡ JVMÀ» ¿­¾î¼­ À¥¼­¹ö process ÁÖ¼Ò °ø°£¿¡¼­ TomcatÀ» ³»ºÎÀûÀ¸·Î ½ÇÇàÇÕ´Ï´Ù. ÀÌ ¹®¼­¿¡¼­´Â ´Ù·çÁö ¾Ê´Â ³»¿ëÀÔ´Ï´Ù.

Web server plugin/tomcat redirector

TomcatÀÌ ´Ù¸¥ À¥¼­¹ö¿Í ÇÔ²² ¿î¿µµÉ ¶§ À¥¼­¹ö¿¡ ¼³Ä¡Çؼ­ À¥¼­¹ö·Î µé¾î¿À´Â servlet ¿äûÀ» TomcatÀ¸·Î º¸³»´Â ¿ªÇÐÀ» ÇÕ´Ï´Ù. À¥¼­¹ö Ç÷¯±×ÀÎÀÌ°í, ÀÌ ¹®¼­¿¡¼­´Â À¥¼­¹öÇ÷¯±×ÀÎÀ¸·Î mod_jk¸¦ ¼Ò°³ÇÕ´Ï´Ù. ÀÌ Àü¼ÛÀÚ´Â ¼­¹ö¿¡ Ç÷¯±×ÀÎ µÇ±â À§ÇØ DLL(win32) / shared object(linux) ¸ðµâ ÇüÅ·ΠµÇ¾î ÀÖ½À´Ï´Ù.

Plugin configuration

¿©·¯ ´Ù¸¥ Tomcat worker°¡ µ¿ÀÛÇÒ °æ¿ì ¿äûÀÌ ¾î´À °÷À¸·Î Àü´ÞµÇ¾ß ÇÒ Áö ±¸ºÐÇϱâ À§ÇØ À¥¼­¹öÇ÷¯±×ÀÎÀ» ¼³Á¤ÇÒ ÇÊ¿ä°¡ ÀÖ½À´Ï´Ù. ·Î±×·¹º§ °°Àº ¸î°¡Áö ³»ºÎ ÆĶó¹ÌÅÍ¿¡ ¼ö¹ÝµÈ ÀÌ Á¤º¸°¡ Ç÷¯±×ÀÎ ¼³Á¤À» ±¸¼ºÇÕ´Ï´Ù.

Web server configuration

°¢°¢ÀÇ ¼­¹ö´Â ¾î¶»°Ô µ¿ÀÛÇÏ´ÂÁö Á¤ÀÇÇØÁÖ´Â ¼³Á¤À» °¡Áö°í ÀÖ½À´Ï´Ù. ¿¹¸¦ µé¸é ¾î´À Æ÷Æ®¸¦ »ç¿ëÇÏ´ÂÁö, ¾î¶² ÆÄÀÏÀ» º¸³¾Áö, ¾î¶² À¥¼­¹ö Ç÷¯±×ÀÎÀ» ºÒ·¯¿Í¾ß µÇ´ÂÁö µîµîÀÌÁÒ. Tocmat Àü´ÞÀÚ¸¦ ºÒ·¯¿Í »ç¿ëÇϱâ À§ÇØ À¥¼­¹ö ¼³Á¤À» ¼öÁ¤ÇØÁÖ¾î¾ßÇÕ´Ï´Ù.


Apache¿¡¼­ÀÇ mod_jk ¼³Ä¡

¼³Ä¡¼ø¼­´Â ´ÙÀ½°ú °°½À´Ï´Ù:

  1. ÀÌÀü mod_jserv ¼³Ä¡¸¦ Á¦°ÅÇÕ´Ï´Ù. mod_jk ¿Í mod_jserv ÇÔ²² ¸ø¾¹´Ï´Ù!!
  2. mod_jk ´Ù¿î¹Þ½À´Ï´Ù.
  3. (¼±ÅÃ) Tomcat ¿¡¼­ Ajpv13 protocol ¸¦ »ç¿ëÇϵµ·Ï ¼³Á¤ÇÕ´Ï´Ù.
  4. mod_jk »ç¿ëÇÒ worker ¸¦ Á¤ÀÇÇÕ´Ï´Ù.(¶Ç´Â quick start ¿É¼ÇÀ» »ç¿ëÇÕ´Ï´Ù.)
  5. mod_jk ¿¡ ¸Â°Ô Apache¸¦ ¼öÁ¤ÇÕ´Ï´Ù. ±×¸®°í mod_jk ³»ºÎµµ Á¶Á¤ÇÕ´Ï´Ù. (¶Ç´Â quick start ¿É¼Ç »ç¿ë)
  6. Tomcat¿¡ º¸³»Áú URL À» ÁöÁ¤ÇÕ´Ï´Ù. (¶Ç´Â quick start ¿É¼Ç »ç¿ë)

1. mod_jserv Áö½ÃÀÚ Á¦°ÅÇϱâ

Apache¿¡ mod_jserv°¡ ¼³Ä¡µÇ¾ú´Ù¸é, httpd.conf ÆÄÀÏ¿¡¼­ ApJServMount Áö½ÃÀÚ¸¦ ¸ðµÎ Á¦°ÅÇÕ´Ï´Ù. ¸¸ÀÏ tomcat-apache.conf ³ª tomcat.conf¸¦ Æ÷ÇÔÇÏ°í ÀÖ´Ù¸é ¿ä ÁÙµµ Áö¿öÁÝ´Ï´Ù. ÀÌ°ÍÀº mod_jserv¿¡ ¸ÂÃçÁ® ÀÖ½À´Ï´Ù.

2. mod_jk ±¸Çϱâ, ¸¸µé±â

Tomcat ¹èÆ÷ÆÇÀ» ¹Þ¾Ò´ø °÷ÀÇ bin µð·ºÅ丮¿¡¼­ Linux¿Í Win32¿ë Binaries ÆÄÀÏµé ±¸ÇÒ ¼ö ÀÖ½À´Ï´Ù. Linux ¿¡¼­´Â mod_jk.so ·Î, Win32¿¡¼­´Â mod_jk.dll ·Î µÇ¾îÀÖ½À´Ï´Ù. ¸¸µé¾îÁø mod_jk °¡ ¾ø´Ù¸é ¼Õ¼ö ¸¸µå¼Å¾ßÁÒ. ¼Ò½º·ÎºÎÅÍ Á÷Á¢ ¸¸µé ¼ö ÀÖ½À´Ï´Ù. ¸ÕÀú, Tomcat ¿ë Source ¹èÆ÷ÆÇÀ» ´Ù¿î¹Þ½À´Ï´Ù. ´Ù¿î·Îµå µð·ºÅ丮°¡ ¹«ÁøÀå ¸¹Áö¸¸ jakarta-tomcat ¸¸ ã¾Æ¼­ ´Ù¿î¹ÞÀ¸¸é µË´Ï´Ù.

NT ¿¡¼­

Visual C++ Ver.6.0À¸·Î ¸¸µì´Ï´Ù. Á÷Á¢ ¸¸µé±â À§Çؼ­´Â ÀÌ°Ô ±ò·ÁÀÖ¾î¾ß µË´Ï´Ù.

¼ø¼­´Â ´ÙÀ½°ú °°½À´Ï´Ù.:

  1. apache1.3/apache2.0 ¼Ò½º µð·ºÅ丮·Î À̵¿ÇÕ´Ï´Ù. µµ½ºÃ¢¿¡¼­¿ä.
  2. APACHE1_HOME ȯ°æº¯¼ö¸¦ Apache°¡ ¼³Ä¡µÈ °÷ÀÇ À§Ä¡¸¦ ÁöÁ¤ÇØÁÝ´Ï´Ù.
  3. ´ÙÀ½°ú °°ÀÌ Command ÁÙ¿¡ ÀÔ·ÂÇÕ´Ï´Ù.:

    MSDEV mod_jk.dsp /MAKE ALL

    msdev °¡ path¿¡ ÀâÇô ÀÖÁö ¾Ê´Ù¸é, msdev.exeÀÇ full path¸¦ ÀÔ·ÂÇÕ´Ï´Ù. ±×¸®°í, ApacheCore.lib ÆÄÀÏÀÌ ÄÄÆÄÀÏ µÇ±â Àü¿¡ APACHE1_HOME\src\CoreD ¿Í APACHE1_HOME\src\CoreR µð·ºÅ丮¿¡ °¢°¢ ÀÖ¾î¾ß ÇÕ´Ï´Ù. ÀÌµé ¶óÀ̺귯¸®¸¦ »ý¼ºÇϱâ À§ÇØ ÃæºÐÇÑ Apache ¼Ò½º¸¦ build ÇÒ ÇÊ¿ä°¡ ÀÖ½À´Ï´Ù.
  4. ¸¸µé¾îÁø mod_jk.dll ¸¦ ApacheÀÇ modules µð·ºÅ丮¿¡ º¹»çÇÕ´Ï´Ù..

ÀÌ°ÍÀº ¹èÆ÷ÆÇ°ú µð¹ö±×¹öÀüÀ» ¸ðµÎ ¸¸µì´Ï´Ù(mod_jk).

´Ù¸¥ ¹æ¹ý: mod_jk.dsp ÆÄÀÏÀ» msdev¿¡¼­ ¿­¾î¼­ build ¸Þ´º·Î ¸¸µé¾îµµ µË´Ï´Ù.

UNIX ¿¡¼­

Apache ¿ë

  1. Perl 5 ¼³Ä¡µÇ¾î ÀÖ¾î¾ß ÇÕ´Ï´Ù. ¸ðµâÀ» ¸¸µå´Â apxs ½ºÅ©¸³Æ®°¡ Perl·Î Â¥Á®ÀÖ½À´Ï´Ù.
  2. jakarta-tomcat/src/native/apache1.3 (¶Ç´Â apache2.0) ·Î À̵¿ÇÕ´Ï´Ù.
  3. apache ¹èÆ÷ÆÇ¿¡ ÀÖ´Â apxs ¸í·ÉÀ» µ¹¸³´Ï´Ù. (hint: /usr/local/apache/bin, /usr/sbin, ¶Ç´Â Apache ÀνºÅç µÈ °÷À» ã¾Æº¸¼¼¿ä.). ÇÑÁÙ·Î ¾Æ·¡ ¸í·ÉÀ» ´Ù Ĩ´Ï´Ù.

    Solaris :
    apxs -o mod_jk.so -DSOLARIS -I../jk -I/usr/java/include -I/usr/java/include/solaris -c *.c ../jk/*.c
    ½Ã½ºÅÛº°·Î Àß µÇ°ÚÁö¸¸, ¸¸ÀÏ "symbol "fdatasync" not found" ¿¡·¯°¡ ³¯ ¶§°¡ ÀÖ½À´Ï´Ù. ¼öÁ¤ÇÏ·Á¸é, -lposix4 ¸¦ -c ¾Õ¿¡ Ãß°¡ÇØ ÁÖ½Ã¸é µË´Ï´Ù.

    Linux:
    apxs -o mod_jk.so -I../jk -I/usr/local/jdk/include -I/usr/local/jdk/include/linux -c *.c ../jk/*.c
    ¼Ò½º µð·ºÅ丮°¡ ¾Æ´Ñ ../jk µð·ºÅ丮¿¡¼­ ³ª¿Â objects ÆÄÀϵéÀÌ ÇöÀç µð·ºÅ丮¿¡ ÄÄÆÄÀϵDZ⠶§¹®¿¡ ½ÇÆÐÇÒ ¼öµµ ÀÖ½À´Ï´Ù. ±× ¶§´Â gcc -shared -o mod_jk.so *.o ¸¦ µ¹·Á¼­ build ¸¦ ¸¶ÃÄ¾ß ÇÕ´Ï´Ù.

    (´Ù¸¥ µð·ºÅ丮¿¡ Java¸¦ ÀνºÅçÇß´Ù¸é °Å±â¿¡ ¸ÂÃçÁÖ¼¼¿ä.). ³¡¸¶ÃÄ¾ß ÇÕ´Ï´Ù¸¸ ±â¾ïÇÒ °ÍÀº apxs ¿¡ ÀÖ´Â argumentsµéÀÇ ¼ø¼­´Â Áß¿äÇÏ´Ù!´Â °ÍÀÔ´Ï´Ù. For other *nixes you should be able to work it out, but remember that the order of the arguments to apxs is important!.
  4. mod_jk.so ¸¦ ApacheÀÇ libexec µð·ºÅ丮¿¡ º¹»çÇÕ´Ï´Ù.

´Ù¸¥ À¥¼­¹öµé

¿©·¯°¡Áö Makefiles ÀÌ jakarta-tomcat/src/native µð·ºÅ丮ÀÇ ÇϺΠµð·ºÅ丮¿¡ ÀÖ½À´Ï´Ù.

3. (¼±ÅÃ) Tomcat¿¡¼­ Ajpv13 protocol »ç¿ëÇϱâ

mod_jk ´Â ¿øº» Ajpv12 protocol ¶Ç´Â »õ·Î¿î Ajpv13 protocol ¾çÂÊ´Ù »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ÈÄÀÚ¸¦ ¼±ÅÃÇß´Ù¸é, "Ajp13" Ä¿³Ø¼ÇÇڵ鷯¸¦ ÅèĹ¿¡¼­ µ¿ÀÛ½ÃÄÑ¾ß ÇÕ´Ï´Ù. ÀÌ·ÎÀÎÇØ »¡¶óÁø ÇÁ·ÎÅäÄÝÀÇ ÀÕÁ¡°ú HTTPS¸¦ ÅëÇÑ ¿äûÀ» ±¸ºÐÇس¾ ¼ö ÀÖ´Â ´É·ÂÀ» °®°Ô µË´Ï´Ù.

¾Æ·¡ Äڵ带 TOMCAT_HOME/conf/server.xml ÆÄÀÏ¿¡ Ãß°¡ÇØ ÁֽʽÿÀ.
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
  <Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp13ConnectionHandler"/>
  <Parameter name="port" value="8009"/>
</Connector>
ÀÌ¹Ì servlet.xml ÆÄÀÏÀº ÀÌ ºÎºÐ°ú À¯»çÇÑ 8007Æ÷Æ®¸¦ »ç¿ëÇÏ´Â Ajp12 connections À» Æ÷ÇÔÇÏ°í ÀÖ½À´Ï´Ù(mod_jserv ¿¡ ÀÇÇØ Àü´ÞµÊ). Ajp13¸¸ »ç¿ëÇÏ°í ½Í¾îµµ, Ajp12 Ä¿³ØÅ͸¦ Áö¿ìÁö ¸¶½ÃÁÒ(?) - TomcatÀÇ shutdown¿¡ ÇÊ¿äÇÏ´ð´Ï´Ù.

4. "workers" Á¤ÀÇÇϱâ

Quick start?

´ëºÎºÐ ´Ü¼øÇÑ °æ¿ì TomcatÀº Apache¿¡ ÇÊ¿äÇÑ È¯°æ¼³Á¤ ÆÄÀϵéÀ» »ý¼ºÇÕ´Ï´Ù. Tomcat ÀÌ ±¸µ¿ÇÒ ¶§ Apache ¸¦ À§ÇØ TOMCAT_HOME/conf/mod_jk.conf-auto ÆÄÀÏÀ» ÀÚµ¿À¸·Î »ý¼ºÇÕ´Ï´Ù. ¿ì¸®°¡ ÇÒ ÀÏÀº ´ÜÁö ÀÌ ÆÄÀÏÀ» httpd.conf ÆÄÀÏ¿¡ ´ÙÀ½°ú °°ÀÌ ÇÑÁÙÀ» ÷°¡ÇÏ´Â °Í »ÓÀÔ´Ï´Ù.
"Include TOMCAT_HOME/conf/mod_jk.conf-auto"
Ok, ÀÌÁ¦ Tomcat °ú Apache¸¦ ½ÃÀÛÇϸé Apache¼­¹ö¿¡¼­ Tomcat¿¡ Á¢±ÙÇÒ ¼ö ÀÖ½À´Ï´Ù.

Ưº°ÇÑ °æ¿ì, ¿¹¸¦ µé¸é ±âº»°ªÀÌ ¾Æ´Ñ URL prefixes ¸¶¿îÆà ½Ã¿¡ ÀÌ ÆÄÀÏÀ» Ä¿½ºÅ͸¶ÀÌÁîµÈ ¼³Á¤ÀÇ ±â¹ÝÀ¸·Î »ï°í, ´Ù¸¥ ÆÄÀÏ À̸§À¸·Î ÀúÀåÇÕ´Ï´Ù. Apache¸¦ Á÷Á¢ °ü¸®ÇÑ´Ù¸é »õ·Î¿î ÄÁÅؽºÆ®°¡ Ãß°¡µÉ ¶§¸¶´Ù Apache¸¦ UpdateÇؾßÇÕ´Ï´Ù.

Tomcat 3.2: »õ context ¸¦ Ãß°¡ÇÑ µÚ¿¡ tomcat°ú apache ¸ðµÎ Àç½ÃÀÛÇؾßÇÕ´Ï´Ù; Apache´Â Àç½ÃÀÛÇؾ߸¸ º¯È­µÈ ¼³Á¤°ªÀÌ Àû¿ëµË´Ï´Ù.
¶ÇÇÑ, TOMCAT_HOME/conf/mod_jk.conf-auto ÆÄÀÏÀº tomcatÀÌ ½ÃÀÛÇÒ ¶§ »ý¼ºµÇ¹Ç·Î, Apache¸¦ ½ÃÀÛÇϱâ Àü¿¡ TomcatÀ» ½ÃÀÛÇؾßÇÕ´Ï´Ù. TomcatÀº ¸Å¹ø »õ·Î ½ÃÀÛÇÒ ¶§¸¶´Ù TOMCAT_HOME/conf/mod_jk.conf-auto ÆÄÀÏÀ» µ¤¾î¾¹´Ï´Ù.

¼öµ¿ workers ¼³Á¤.

Worker´Â TOMCAT_HOME/conf/workers.properties ÆÄÀÏ·Î ¼³Á¤µË´Ï´Ù. workers.properties howto ¹®¼­¿¡´Â »ó´çÇÑ ºÐ·®ÀÇ Á¤º¸°¡ ÀÖ°í, ¸ÕÀú ¾Ë°í ÀÖ¾î¾ß ÇÕ´Ï´Ù. ±×·¯³ª, ±ÞÇϽôٸé workers.properties ÆÄÀÏÀ» ÆíÁýÇÏ°í workers.tomcat_home, workers.java_home ÆÄÀÏ°ú ½Ã½ºÅÛ¿¡ ¸Â´Â ps º¯¼ö°ªµéÀ» ¼¼ÆÃÇÏÁö ¾Ê¾Æµµ µË´Ï´Ù.

5. Apache¿¡¼­ÀÇ mod_jk ¼³Ä¡

mod_jk¸¦ »ç¿ëÇϱâ À§ÇÑ Apache ¼³Á¤¹ýÀº Apache ¼­¹ö ¼³Á¤ Áö½ÃÀÚ¸¦ ÅëÇØ ÀÌ·ç¾îÁø´Ù; ½ÃÀÛÇÏ·Á¸é ÀÚµ¿ »ý¼ºµÈ Tomcat ÀÇ conf Æú´õ¿¡ ÀÖ´Â mod_jk.conf-auto ÆÄÀÏÀ» º»´Ù.

httpd.conf ÆÄÀÏ¿¡¼­ ´ÙÀ½°ú °°Àº ÇüÅ·ΠÀÛ¼ºÇØÁÖ¸é µË´Ï´Ù:
LoadModule    jk_module  libexec/mod_jk.so
AddModule     mod_jk.c
JkWorkersFile /usr/local/jakarta-tomcat/conf/workers.properties
JkLogFile     /usr/local/apache/logs/mod_jk.log
JkLogLevel    warn

6. Tomcat È£ÃâÇÏ´Â URL ÇÒ´ç

mod_jkÀÇ JkMount Áö½ÃÀÚ¸¦ »ç¿ëÇØ ÁöÁ¤µÈ URL µéÀ» TomcatÀ¸·Î ÇÒ´çÇÒ ¼ö ÀÖ½À´Ï´Ù. ÀϹÝÀûÀ¸·Î JkMount Áö½ÃÀÚÀÇ ±¸Á¶´Â ´ÙÀ½°ú °°½À´Ï´Ù:

JkMount <URL prefix> <Worker name>

¿¹¸¦ µé¾î ´ÙÀ½ÀÇ Áö½ÃÀÚµéÀº .jsp·Î ³¡³ª´Â ¿äûµéÀ̳ª /servlet À¸·Î ½ÃÀÛÇÏ´Â ¸ðµç ¿äûµéÀº "ajp13" worker·Î º¸³À´Ï´Ù. ±×·¯³ª /otherworker ¿¡ ÀÖ´Â .jsp ¿äûÀº "remoteworker" ·Î º¸³À´Ï´Ù.

JkMount /*.jsp ajp13
JkMount /servlet/* ajp13
JkMount /otherworker/*.jsp remoteworker
httpd.conf ÆÄÀÏ¿¡¼­ JkMount Áö½ÃÀÚ¸¦ Top·¹º§ À̳ª <VirtualHost> ¼½¼Ç ³»ºÎ¿¡ µÒÀ¸·Î »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.

³¡³µ½À´Ï´Ù! ÀÌÁ¦ Tomcat°ú apache¸¦ ½ÃÀÛÇÔÀ¸·Î µÎ ¼­¹ö°¡ µ¿ÀÛÇϸ鼭 ¼­ºí¸´°ú JSP ÆÄÀϵéÀ» µ¹¸± ¼ö ÀÖ½À´Ï´Ù.


¼³Á¤¿¹

Here's an example configuration which probably reflects many real-world setups. A site is using Tomcat and Apache with two virtual hosts (one of them using HTTPS as well, which we're assuming is being handled by mod_ssl).

URLs ending in .jsp and beginning with /servlet are handled by Tomcat, the rest are handled by Apache. The files for each Host are server out of /web/host1 and /web/host2 respectively.

The example are over-simplified and incomplete but should get you started. Also note the virtual host setup is new in Tomcat 3.2 - this example won't work with Tomcat 3.1.

.
.
<Connector className="org.apache.tomcat.service.PoolTcpConnector">
  <Parameter name="handler" value="org.apache.tomcat.service.connector.Ajp12ConnectionHandler"/>
  <Parameter name="port" value="8007"/>
</Connector>

<Connector className="org.apache.tomcat.service.PoolTcpConnector">
  <Parameter name="handler"  value="org.apache.tomcat.service.connector.Ajp13ConnectionHandler"/>
  <Parameter name="port" value="8009"/>
</Connector>

<Host name="host1.apache.org">
  <Context path="" docBase="/web/host1" debug="0"/>
</Host>
<Host name="host2.apache.org">
  <Context path="" docBase="/web/host2" debug="0"/>
</Host>
.
.
Table 1 - Excerpt from server.xml showing the Ajp13 Connector and two virtual hosts.

# Setup for Solaris system
#
workers.tomcat_home=/usr/local/jakarta-tomcat
workers.java_home=/usr/java
ps=/
worker.list=ajp12, ajp13

# Definition for Ajp13 worker (Ajp12 left to readers imagination)
#
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
Table 2 - Excerpt from workers.properties showing the Ajp13 worker

# Load mod_jk
#
LoadModule    jk_module  libexec/mod_jk.so
AddModule     mod_jk.c

# Configure mod_jk
#
JkWorkersFile /usr/local/jakarta-tomcat/conf/workers.properties
JkLogFile     /usr/local/apache/logs/mod_jk.log
JkLogLevel    warn

# First Virtual Host.
#
<VirtualHost 10.0.0.1:80>
  DocumentRoot /web/host1
  ServerName host1.apache.org
  JkMount /*.jsp ajp13
  JkMount /servlet/* ajp13
</VirtualHost>

# Second Virtual Host. Also accessible via HTTPS
#
<VirtualHost 10.0.0.2:80>
  DocumentRoot /web/host2
  ServerName host2.apache.org
  JkMount /*.jsp ajp13
  JkMount /servlet/* ajp13
</VirtualHost>

<VirtualHost 10.0.0.2:443>
  DocumentRoot /web/host2
  ServerName host2.apache.org
  SSLEngine On
  JkMount /*.jsp ajp13
  JkMount /servlet/* ajp13
</VirtualHost>

Table 3 - Excerpt from Apaches httpd.conf showing JK directives.

Troubleshooting °ú F.A.Q.s

Q. mod_jk¸¦ µµ´ëü ¾îµð¿¡¼­ ãÀ» ¼ö ÀÖ³ª¿ä? ¾îµø¾î¿ä?

A. Tomcat ÀÇ ¼Ò½º ¹èÆ÷ÆÇÀ» ¹Þ¾Æ¼­ Á÷Á¢ ÄÄÆÄÀÏ(build)ÇØ¾ß ÇÕ´Ï´Ù. ÀÚ¼¼ÇÑ ³»¿ëÀº ÀÌ ¼½¼ÇÀ» Âü°íÇϼ¼¿ä

Q. ¾î¶² protocol À» »ç¿ëÇØ¾ß Çմϱî? Ajp12 or Ajp13?

A. Ajp13 Àº »õ·Î¿î ÇÁ·ÎÅäÄÝÀÌ°í, ºü¸¨°í, SSL°úµµ Àß µ¿ÀÛÇÕ´Ï´Ù. You almost certainly want to use that. There is more information in the workers.properties howto document

Q. Tomcat Àç½ÃÀÛÇÒ ¶§¸¶´Ù, Apache °¡ Á×½À´Ï´Ù!

A. Ajp13 ÇÁ·ÎÅäÄÝÀº Tomcat°ú Apache »çÀÌ¿¡¼­ ¿ÀÇ ¼ÒÄÏÀ» À¯ÁöÇÕ´Ï´Ù. TomcatÀ» Àç½ÃÀÛÇÒ ¶§ Apacheµµ ¿ª½ÃÀç½ÃÀÛÇØÁà¾ß ÇÕ´Ï´Ù.

Q. ´õ ÀÚ¼¼ÇÑ Á¤º¸´Â?

A. The workers.properties howto ¹®¼­¿¡´Â ¿©±âº¸´Ù »ó´çÈ÷ °í±Þ ¼öÁØÀÇ Á¤º¸°¡ ÀÖ½À´Ï´Ù. Çѹøº¼¸¸ ÇÕ´Ï´Ù. ¶Ç´Â "mod_jk" ¸ÞÀϸµ ¸®½ºÆ®¿¡ °¡ÀÔÇϰųª mod_jk ¼Ò½º¸¦ Á÷Á¢ ºÐ¼®ÇÏ´Â °ÍÀÌÁÒ.

Credits

This document was created by Gal Shachor, and was revised by Mike Bremford with help from the countless many on the tomcat-dev and tomcat-user lists!

Copyright ©1999-2000 The Apache Software Foundation
Legal Stuff They Make Us Say
Contact Information