{"id":2387,"date":"2013-11-27T16:52:43","date_gmt":"2013-11-27T07:52:43","guid":{"rendered":"https:\/\/www.united-bears.co.jp\/blog\/?p=2387"},"modified":"2013-11-27T16:52:43","modified_gmt":"2013-11-27T07:52:43","slug":"apache-2-2-x-%e3%81%a8-tomcat-%e3%81%ae%e9%80%a3%e6%90%ba1-%ef%bd%9emod_proxy_ajp-%e3%81%ae%e5%88%a9%e7%94%a8%ef%bd%9e","status":"publish","type":"post","link":"https:\/\/www.united-bears.co.jp\/blog\/archives\/2387","title":{"rendered":"Apache 2.2.x \u3068 Tomcat \u306e\u9023\u643a(1) \uff5emod_proxy_ajp \u306e\u5229\u7528\uff5e"},"content":{"rendered":"<p>Apache 2.2.x \u3068 Tomcat 6.0.x\/Tomcat 7.0.x \u3092 mod_proxy_ajp \u3092\u5229\u7528\u3057\u3066\u9023\u643a\u3059\u308b\u3068\u304d\u3001\u4ee5\u524d\u306e\u8a2d\u5b9a\u3092\u30b3\u30d4\u30fc\u3057\u305f\u308a\u77e5\u3063\u3066\u3044\u308b\u306f\u305a\u306e\u3053\u3068\u3092\u8abf\u3079\u305f\u308a\u3057\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u30e1\u30e2\u3068\u3057\u3066\u6b8b\u3059\u3053\u3068\u306b\u3057\u305f\u3002\u74b0\u5883\u306f\u3001Cent OS 6.4 \u3068\u3001<a href=\"http:\/\/tomcat.apache.org\/\" target=\"_blank\">Apache Tomcat<\/a>\u304b\u3089\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u305f Tomcat 6.0.x\/Tomcat 7.0.x \u3092\u60f3\u5b9a\u3057\u3066\u3044\u308b\u3002\u30c6\u30b9\u30c8\u3057\u305f Apache \u306e\u30d0\u30fc\u30b8\u30e7\u30f3\u306f\u30012.2.15\u3060\u3002<\/p>\n<h2>\u5fc5\u8981\u306a\u30e2\u30b8\u30e5\u30fc\u30eb<\/h2>\n<p>mod_proxy \u3068 mod_proxy_ajp \u304c\u5fc5\u8981\u306b\u306a\u308b\u3002httpd.conf \u3082\u3057\u304f\u306f httpd.conf \u304c\u30a4\u30f3\u30af\u30eb\u30fc\u30c9\u3059\u308b\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u3001\u4ee5\u4e0b\u306e\u8a18\u8ff0\u304c\u5fc5\u8981\u3060\u3002<\/p>\n<pre>\r\nLoadModule proxy_module modules\/mod_proxy.so\r\nLoadModule proxy_ajp_module modules\/mod_proxy_ajp.so\r\n<\/pre>\n<h2>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u3068 URL \u304c\u4e00\u81f4\u3059\u308b\u5834\u5408<\/h2>\n<p>\u6700\u3082\u5358\u7d14\u306a\u306e\u306f\u3001Apache \u306e URL \u306e\u30d1\u30b9\u3068 Tomcat \u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u304c\u540c\u4e00\u306e\u5834\u5408\u3067\u3042\u308b\u3002\u5177\u4f53\u7684\u306a\u4f8b\u3092\u6319\u3052\u308b\u3068 Tomcat \u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u304c\u300c\/app\u300d\u3067\u3001Apache \u3068\u9023\u643a\u3057\u305f\u3068\u304d\u306b\u300chttp:\/\/192.168.1.1\/app\u300d\u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u5834\u5408\u3067\u3042\u308b\u3002<\/p>\n<p>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u3068 URL \u304c\u4e00\u81f4\u3059\u308b\u5834\u5408\u306f\u3001\u5358\u7d14\u306b ProxyPass \u3092\u8a2d\u5b9a\u3059\u308b\u3060\u3051\u3067\u3088\u3044\u3002\u4ee5\u4e0b\u306f\u3001Apache \u304c192.168.1.1\u3067 Tomcat \u304c192.168.1.2\u3067\u52d5\u4f5c\u3057\u3066\u304a\u308a\u3001http:\/\/192.168.1.1\/app \u3067\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b\u5834\u5408\u306e\u4f8b\u3067\u3042\u308b\u3002<\/p>\n<pre>\r\nProxyPass \/app ajp:\/\/192.168.1.2:8009\/app\r\n&lt;Location \/app&gt;\r\n...\r\n&lt;\/Location&gt;\r\n<\/pre>\n<p>\u4f59\u8ac7\u3060\u304c\u3001Apache \u306e&lt;Directory&gt;\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u306f\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u7269\u7406\u30d1\u30b9\u306b\u5bfe\u3059\u308b\u30a2\u30af\u30bb\u30b9\u3092\u884c\u3063\u305f\u5834\u5408\u306b\u9069\u7528\u3055\u308c\u308b\u305f\u3081\u3001ProxyPass \u3067\u8a2d\u5b9a\u3057\u305f URL \u3078\u306e\u30a2\u30af\u30bb\u30b9\u3092\u5236\u5fa1\u3059\u308b\u5834\u5408\u306f&lt;Location&gt;\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3092\u4f7f\u7528\u3059\u308b\u3002<\/p>\n<h2>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u3068 URL \u306e\u30d1\u30b9\u304c\u7570\u306a\u308b\u5834\u5408<\/h2>\n<p>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u3068 URL \u304c\u7570\u306a\u308b\u5834\u5408\u3001\u4ee5\u4e0b\u306e2\u3064\u306e\u554f\u984c\u304c\u767a\u751f\u3059\u308b\u3002<\/p>\n<ol>\n<li>HttpServletResponse.sendRedirect() \u30e1\u30bd\u30c3\u30c9\u3092\u5229\u7528\u3057\u305f\u3068\u304d\u3001\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u3068 URL \u306e\u30d1\u30b9\u304c\u7570\u306a\u308b\u305f\u3081\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306f(\u304a\u305d\u3089\u304f)\u30da\u30fc\u30b8\u3092\u898b\u3064\u3051\u3089\u308c\u306a\u3044\n<li>Tomcat \u304c\u767a\u884c\u3057\u305f\u30bb\u30c3\u30b7\u30e7\u30f3\u7528\u306e\u30af\u30c3\u30ad\u30fc(\u901a\u5e38\u306fJSESSIONID)\u306f Path \u306b Tomcat \u306e\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u304c\u5165\u3063\u3066\u3044\u308b\u305f\u3081\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u7dad\u6301\u3067\u304d\u306a\u3044<\/li>\n<\/ol>\n<p>\u308f\u304b\u308a\u306b\u304f\u3044\u306e\u3067\u3001\u5177\u4f53\u4f8b\u3092\u6319\u3052\u3066\u3044\u304f\u3002URL \u306f\u30c9\u30e1\u30a4\u30f3\u306e\u30c8\u30c3\u30d7\u306b\u3057\u305f\u3044\u304c\u3001\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306f app.war \u3068\u3044\u3046\u540d\u524d\u3067\u30c7\u30d7\u30ed\u30a4\u3059\u308b\u3068\u3001\u4e00\u822c\u7684\u306b\u4ee5\u4e0b\u306e\u72b6\u614b\u306b\u306a\u308b\u3002<\/p>\n<ul>\n<li>\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9 : \/app<\/li>\n<li>URL : http:\/\/192.168.1.1\/<\/li>\n<\/ul>\n<p>1\u756a\u76ee\u306e\u554f\u984c\u304b\u3089\u8003\u3048\u3066\u307f\u308b\u3002\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u5185\u3067\u30d6\u30e9\u30a6\u30b6\u30fc\u306b\u30c8\u30c3\u30d7\u30da\u30fc\u30b8\u306b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u305b\u308b\u305f\u3081\u306b\u3001<\/p>\n<pre>\r\nHttpServletResponse response; \/\/ \u3069\u3053\u304b\u304b\u3089\u6e21\u3055\u308c\u305f response\r\nresponse.sendRedirect(\"index.jsp\");\r\n<\/pre>\n<p>\u3068\u3044\u3046\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u3068\u3059\u308b\u3002\u30d7\u30ed\u30b0\u30e9\u30de\u30fc\u304c\u610f\u56f3\u3057\u3066\u3044\u308b\u306e\u306f\u3001\u300cLocation:http:\/\/192.168.123.2\/index.jsp\u300d\u3068\u3044\u3046\u30d8\u30c3\u30c0\u30fc\u304c\u9001\u51fa\u3055\u308c\u308b\u3053\u3068\u3060\u304c\u3001\u5b9f\u969b\u306b\u306f\u73fe\u5728\u306e\u30ea\u30af\u30a8\u30b9\u30c8 URI \u304b\u3089\u306e\u76f8\u5bfe\u8868\u8a18\u3001\u3082\u3057\u304f\u306f\u30b3\u30f3\u30c6\u30ca\u304b\u3089\u306e\u76f8\u5bfe\u8868\u8a18\u3067\u3042\u308b\u3068\u8b58\u5225\u3055\u308c\u308b\u3002\u5f93\u3063\u3066\u76f8\u5bfe URL \u3067\u6307\u5b9a\u3059\u308b\u3068\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d1\u30b9\u304c\u3064\u3044\u305f URL\u3001\u305f\u3068\u3048\u3070\u300cLocation:http:\/\/192.168.123.2\/app\/index.jsp\u300d\u3068\u3044\u3046\u30d8\u30c3\u30c0\u30fc\u3092\u9001\u51fa\u3059\u308b\u3002\u3053\u308c\u3092\u4fee\u6b63\u3057\u3066\u304f\u308c\u308b\u306e\u304c\u3001\u300cProxyPassReverse\u300d\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3060\u3002\u4eca\u56de\u306e\u4f8b\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<pre>\r\nProxyPass \/ ajp:\/\/192.168.1.2:8009\/app\r\nProxyPassReverse \/ http:\/\/192.168.1.1\/app\r\n<\/pre>\n<p><a href=\"http:\/\/httpd.apache.org\/docs\/2.2\/ja\/mod\/mod_proxy.html#proxypassreverse\" target=\"_blank\">Apache \u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306b\u8a18\u8ff0\u304c\u3042\u308b\u3068\u304a\u308a\u3001ProxyPass \u3092\u5229\u7528\u3057\u3066\u3044\u308b URL \u306b\u95a2\u9023\u3059\u308b\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u304c\u30d8\u30c3\u30c0\u30fc\u306b\u542b\u307e\u308c\u308b\u5834\u5408\u3001ProxyPassReverse \u306f\u300chttp:\/\/192.168.1.1\/app\u300d\u3078\u306e\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3092\u300chttp:\/\/192.168.1.1\/\u300d\u306b\u5909\u63db\u3059\u308b\u3002<\/p>\n<p>2\u756a\u76ee\u306e\u554f\u984c\u306f\u3001Tomcat \u304c\u767a\u884c\u3059\u308b JSESSIONID \u306e\u30af\u30c3\u30ad\u30fc\u306b\u542b\u307e\u308c\u308b Path \u306e\u554f\u984c\u3060\u3002\u30d6\u30e9\u30a6\u30b6\u30fc\u306f\u3001\u30af\u30c3\u30ad\u30fc\u306b\u8a2d\u5b9a\u3055\u308c\u305f\u30c9\u30e1\u30a4\u30f3\u3084\u30d1\u30b9\u3092\u898b\u3066\u3001\u30af\u30c3\u30ad\u30fc\u3092\u9001\u51fa\u3059\u3079\u304d\u304b\u5224\u65ad\u3059\u308b\u3002\u4eca\u56de\u306e\u4f8b\u3067\u306f\u3001Tomcat<br \/>\n\u306f\u300cSet-Cookie:JSESSIONID=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; Path=\/app\/\u300d\u3068\u3044\u3046\u30d8\u30c3\u30c0\u30fc\u3092\u51fa\u529b\u3059\u308b\u3060\u308d\u3046\u3002\u3057\u304b\u3057\u30d6\u30e9\u30a6\u30b6\u30fc\u304c\u30a2\u30af\u30bb\u30b9\u3059\u308b URL \u306f\u300chttp:\/\/192.168.1.1\/\u300d\u3067\u30d1\u30b9\u306f\u300c\/\u300d\u3001\u30af\u30c3\u30ad\u30fc\u306e\u30d1\u30b9\u3068 URL \u306e\u30d1\u30b9\u304c\u4e00\u81f4\u3057\u306a\u3044\u306e\u3067\u30af\u30c3\u30ad\u30fc\u3092\u9001\u51fa\u3057\u306a\u3044\u3002Tomcat \u306f\u30af\u30c3\u30ad\u30fc\u306e\u5024\u3092\u53d6\u5f97\u3067\u304d\u306a\u3044\u305f\u3081\u3001\u30bb\u30c3\u30b7\u30e7\u30f3\u3092\u7dad\u6301\u3067\u304d\u306a\u3044\u3002\u3053\u308c\u3092\u4fee\u6b63\u3057\u3066\u304f\u308c\u308b\u306e\u304c\u3001\u300cProxyPassReverseCookiePath\u300d\u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3060\u3002\u4eca\u56de\u306e\u4f8b\u3067\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3002<\/p>\n<pre>\r\nProxyPass \/ ajp:\/\/192.168.1.2:8009\/app\r\nProxyPassReverse \/ http:\/\/192.168.1.1\/app\r\nProxyPassReverseCookiePath \/app \/\r\n<\/pre>\n<p><a href=\"http:\/\/httpd.apache.org\/docs\/2.2\/ja\/mod\/mod_proxy.html#proxypassreversecookiepath\" target=\"_blank\">Apache \u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u306b\u8a18\u8ff0\u304c\u3042\u308b\u3068\u304a\u308a\u3001Set-Cookie \u30d8\u30c3\u30c0\u5185\u306e path \u6587\u5b57\u5217\u3092\u66f8\u304d\u63db\u3048\u3066\u304f\u308c\u308b\u3002<\/p>\n<p>Apache \u306b\u306f ProxyPassReverseCookieDomain \u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3082\u7528\u610f\u3055\u308c\u3066\u304a\u308a\u3001\u30af\u30c3\u30ad\u30fc\u306e\u30c9\u30e1\u30a4\u30f3\u6587\u5b57\u5217\u3092\u8abf\u6574\u3057\u3066\u304f\u308c\u308b\u3002\u4eca\u56de\u306e\u74b0\u5883\u3067\u306f\u3001Tomcat \u304b\u3089\u9001\u51fa\u3055\u308c\u305f\u30af\u30c3\u30ad\u30fc\u306b Domain \u306e\u6307\u5b9a\u306f\u306a\u304b\u3063\u305f(\u3053\u306e\u5834\u5408\u540c\u4e00\u30c9\u30e1\u30a4\u30f3\u306e\u307f\u8a31\u53ef\u3059\u308b)\u306e\u3067\u3001ProxyPassReverseCookieDomain \u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u306f\u4f7f\u3063\u3066\u3044\u306a\u3044\u3002\u30af\u30c3\u30ad\u30fc\u306b Domain \u306e\u6307\u5b9a\u304c\u542b\u307e\u308c\u308b\u5834\u5408\u306f\u3001ProxyPassReverseCookieDomain \u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3092\u4f7f\u3046\u5fc5\u8981\u304c\u3042\u308b\u304b\u3082\u3057\u308c\u306a\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache 2.2.x \u3068 Tomcat 6.0.x\/Tomcat 7.0.x \u3092 mod_proxy_ajp \u3092\u5229\u7528\u3057\u3066\u9023\u643a\u3059\u308b\u3068\u304d\u3001\u4ee5\u524d\u306e\u8a2d\u5b9a\u3092\u30b3\u30d4\u30fc\u3057\u305f\u308a\u77e5\u3063\u3066\u3044\u308b\u306f\u305a\u306e\u3053\u3068\u3092\u8abf\u3079\u305f\u308a\u3057\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u30e1\u30e2\u3068\u3057\u3066\u6b8b [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-2387","post","type-post","status-publish","format-standard","hentry","category-server"],"_links":{"self":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/2387","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/comments?post=2387"}],"version-history":[{"count":12,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/2387\/revisions"}],"predecessor-version":[{"id":2399,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/posts\/2387\/revisions\/2399"}],"wp:attachment":[{"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/media?parent=2387"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/categories?post=2387"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.united-bears.co.jp\/blog\/wp-json\/wp\/v2\/tags?post=2387"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}