{"id":663,"date":"2011-11-07T03:13:59","date_gmt":"2011-11-07T10:13:59","guid":{"rendered":"http:\/\/blog.networkpresence.co\/?p=663"},"modified":"2011-11-07T04:20:51","modified_gmt":"2011-11-07T11:20:51","slug":"tomcat-course-notes-2-centos-mod_jkmod_proxy-apache-tomcat","status":"publish","type":"post","link":"http:\/\/blog.networkpresence.co\/?p=663","title":{"rendered":"Tomcat Course Notes #2 &#8211; CentOS mod_jk\/mod_proxy Apache Tomcat"},"content":{"rendered":"<p>This is another &#8216;brain dump&#8217; of some notes for the Tomcat Admin Course that I&#8217;m presenting in Adelaide on November 7 &#8211; 9 for http:\/\/etc-australia.com<\/p>\n<p>This note is focussed on interfacing Tomcat on port 8080 (HTTP\/1.1) or 8009 (for AJP\/1.3 protocol) to Apache and port 80 access to URLs served by the Tomcat.<\/p>\n<p>ie: So the Tomcat hosted content (webapps) are available via http:\/\/IP-Addr\/ rather than http:\/\/IP-Addr:8080\/<\/p>\n<p>&#8212;<\/p>\n<p>How To Install mod_jk to RHEL\/CentOS &#8216;minimal&#8217; package VPS:<\/p>\n<p>yum -y install httpd-devel<br \/>\nyum -y install gcc-c++<br \/>\nyum -y install make<br \/>\ncd \/usr\/local\/src\/<br \/>\nwget https:\/\/archive.apache.org\/dist\/tomcat\/tomcat-connectors\/jk\/tomcat-connectors-1.2.32-src.tar.gz<br \/>\ntar xzf tomcat-connectors-1.2.32-src.tar.gz<br \/>\ncd tomcat-connectors-1.2.32-src\/native<br \/>\n.\/configure &#8211;with-apxs=\/usr\/sbin\/apxs<br \/>\nmake<br \/>\nmake install<br \/>\nls -latr \/usr\/lib64\/httpd\/modules\/ |grep jk<\/p>\n<p>&#8212;<\/p>\n<p>mod_proxy is installed by CentOS\/RHEL httpd package by default<\/p>\n<p>[root@tomcatcas0 conf]# rpm -qf \/usr\/lib64\/httpd\/modules\/mod_proxy.so<br \/>\nhttpd-2.2.3-53.el5.centos.3<\/p>\n<p>[root@tomcatcas0 conf]# grep -i proxy \/etc\/httpd\/conf\/httpd.conf<br \/>\nLoadModule proxy_module modules\/mod_proxy.so<br \/>\nLoadModule proxy_balancer_module modules\/mod_proxy_balancer.so<br \/>\nLoadModule proxy_ftp_module modules\/mod_proxy_ftp.so<br \/>\nLoadModule proxy_http_module modules\/mod_proxy_http.so<br \/>\nLoadModule proxy_connect_module modules\/mod_proxy_connect.so<br \/>\n# Proxy Server directives. Uncomment the following lines to<br \/>\n# enable the proxy server:<br \/>\n#<IfModule mod_proxy.c><br \/>\n#ProxyRequests On<br \/>\n#<Proxy *><br \/>\n#<\/Proxy><br \/>\n#ProxyVia On<br \/>\n#   CacheRoot &#8220;\/var\/cache\/mod_proxy&#8221;<br \/>\n# End of proxy directives.<\/p>\n<p>[root@tomcatcas0 conf]# diff httpd.conf httpd.conf-mod_jk<br \/>\n201,210c201,206<br \/>\n< ##mod_jk##LoadModule jk_module modules\/mod_jk.so\n< ##mod_jk##\n< ##mod_jk##JkWorkersFile conf.d\/workers.properties\n< ##mod_jk##JkLogFile logs\/mod_jk.log\n< ##mod_jk##JkLogLevel debug\n< \n< ##mod_proxy_ajp##\n< ProxyRequests off\n< ProxyPreserveHost On\n---\n\n--\n\nhttp:\/\/IP-Addr\/docs\/balancer-howto.html\n\nDerived from http:\/\/httpd.apache.org\/docs\/current\/mod\/mod_proxy.html\n\nProxyPass \/ balancer:\/\/mycluster\/ lbmethod=bytraffic\n<Proxy balancer:\/\/mycluster><br \/>\nBalancerMember http:\/\/server1.example.com:8080\/<br \/>\nBalancerMember http:\/\/server2.example.com:8080\/<br \/>\nBalancerMember http:\/\/server3.example.com:8080\/<br \/>\n<\/Proxy><br \/>\nProxyPassReverse \/ http:\/\/www.example.com\/<\/p>\n<p>&#8212;<\/p>\n<p>Apache \/etc\/httpd\/conf\/httpd.conf entries for mod_jk<\/p>\n<p>[root@tomcatcas0 conf]# diff httpd.conf httpd.conf-ORIG<br \/>\n201,207d200<br \/>\n< LoadModule jk_module modules\/mod_jk.so\n< \n< JkWorkersFile conf.d\/workers.properties\n< JkLogFile logs\/mod_jk.log\n< JkLogLevel debug\n\n--\n\nhttp:\/\/adcasein.blogspot.com\/2010\/06\/install-modjk-on-centos-55.html\n\nIf you do have VirtualHosts defined, then be aware that Jkmounts are not inherited in any way. So, or you define JkMount inside all the Virtual hosts you expect to serve your apps, or define them globally and use JkMountCopy in the vhosts.\n\n--\n\nmod_jk workers.properties\n\n[root@tomcatcas0 conf.d]# cat \/etc\/httpd\/conf.d\/workers.properties \n# For Linux\/Unix systems:\n# Setting Tomcat &#038; Java Home\nworkers.tomcat_home=\/usr\/local\/apache-tomcat-6.0.33\nworkers.java_home=\/usr\/lib\/jvm\/jre-1.6.0-openjdk.x86_64\nps=\/\nworker.list=worker1\n# Settings for worker1 worker\nworker.worker1.port=8009\nworker.worker1.host=localhost\nworker.worker1.type=ajp13\n\n--\n\nmod_jk vhost.conf extract \n\n[root@tomcatcas0 conf.d]# cat tomcatjkvhost.conf\n\nJkMount \/* worker1\n\n--\n\nmod_proxy vhost.conf extract\n\n[root@tomcatcas0 conf.d]# cat tomcatproxyvhost.conf\n<Proxy *><br \/>\n Order deny,allow<br \/>\n Allow from all<br \/>\n<\/Proxy><br \/>\nProxyPass \/examples\/jsp ajp:\/\/127.0.0.1:8009\/examples\/jsp<br \/>\nProxyPassReverse \/examples\/jsp ajp:\/\/127.0.0.1:8009\/examples\/jsp<br \/>\n<Location \/examples\/jsp><br \/>\n Order deny,allow<br \/>\n Allow from all<br \/>\n<\/Location><\/p>\n<p>&#8212;<br \/>\n&#8212;<\/p>\n<p>Subsequent Tomcat Course Notes will talk about scaling Tomcats, including DNS, Apache httpd and Tomcat settings, going through to clustering, JDBC, Troubleshooting and much more.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is another &#8216;brain dump&#8217; of some notes for the Tomcat Admin Course that I&#8217;m presenting in Adelaide on November 7 &#8211; 9 for http:\/\/etc-australia.com This note is focussed on interfacing Tomcat on port 8080 (HTTP\/1.1) or 8009 (for AJP\/1.3 &hellip; <a href=\"http:\/\/blog.networkpresence.co\/?p=663\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[94,111,72,110],"class_list":["post-663","post","type-post","status-publish","format-standard","hentry","category-network-presence","tag-apache","tag-mod_jk","tag-tomcat","tag-training"],"_links":{"self":[{"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/posts\/663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=663"}],"version-history":[{"count":21,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":685,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=\/wp\/v2\/posts\/663\/revisions\/685"}],"wp:attachment":[{"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.networkpresence.co\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}