{"id":63650,"date":"2025-04-29T09:49:47","date_gmt":"2025-04-29T01:49:47","guid":{"rendered":"https:\/\/fwq.ai\/blog\/63650\/"},"modified":"2025-04-29T09:49:47","modified_gmt":"2025-04-29T01:49:47","slug":"nginx%e6%80%8e%e4%b9%88%e8%ae%bf%e9%97%aeservlet-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/63650\/","title":{"rendered":"nginx\u600e\u4e48\u8bbf\u95eeservlet"},"content":{"rendered":"<blockquote><p>\n  \u4f7f\u7528 nginx \u8bbf\u95ee servlet \u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u542f\u7528\u5e76\u914d\u7f6e nginx \u7684 ajp \u6a21\u5757\uff0c\u5e76\u5728\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\u4e2d\u914d\u7f6e ajp \u8fde\u63a5\u5668\u3002\u901a\u8fc7 nginx \u7684 location \u5757\u5c06 nginx \u4e0e\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\u8fde\u63a5\uff0c\u4f7f\u7528 ajp \u534f\u8bae\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u3002\u5b8c\u6210\u8fd9\u4e9b\u6b65\u9aa4\u540e\uff0c\u5373\u53ef\u901a\u8fc7 nginx \u8bbf\u95ee servlet\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/03\/2024060321011925193.jpg\" class=\"aligncenter\" title=\"nginx\u600e\u4e48\u8bbf\u95eeservlet\u63d2\u56fe\" alt=\"nginx\u600e\u4e48\u8bbf\u95eeservlet\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u7528 Nginx \u8bbf\u95ee Servlet<\/strong><\/p>\n<p>\u4e3a\u4e86\u7528 Nginx \u8bbf\u95ee Servlet\uff0c\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u542f\u7528 AJP \u6a21\u5757<\/strong><br \/>\u4fee\u6539 Nginx \u914d\u7f6e\u6587\u4ef6\uff08.conf\uff09\uff0c\u542f\u7528 AJP \u6a21\u5757\uff1a<\/p>\n<pre>load_module modules\/ngx_http_ajp_module.so;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u521b\u5efa AJP \u76d1\u542c\u5668<\/strong><\/p>\n<p>\u5728 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u521b\u5efa\u4e00\u4e2a AJP \u76d1\u542c\u5668\uff0c\u901a\u5e38\u4f7f\u7528 8009 \u7aef\u53e3\uff1a<\/p>\n<pre>server {\n    listen 8009 ajp;\n    server_name localhost;\n\n    # ...\u5176\u4ed6 Nginx \u914d\u7f6e\u6307\u4ee4\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u914d\u7f6e\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668<\/strong><\/p>\n<p>\u914d\u7f6e\u60a8\u7684\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\uff08\u4f8b\u5982 Apache Tomcat\uff09\u4ee5\u4f7f\u7528 AJP \u534f\u8bae\u3002\u5728 Tomcat \u7684 server.xml \u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre>&lt;Connector port=\"8009\" protocol=\"AJP\/1.3\" redirectPort=\"8443\" \/&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u5c06 Nginx \u4e0e\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\u8fde\u63a5<\/strong><\/p>\n<p>\u5728 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u4f7f\u7528 location \u5757\u5c06 Nginx \u8fde\u63a5\u5230\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\uff1a<\/p>\n<pre>location \/servlet\/* {\n    proxy_pass http:\/\/localhost:8009;\n    proxy_set_header AJP_REMOTE_ADDR $remote_addr;\n    proxy_set_header AJP_REMOTE_HOST $remote_addr;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u73b0\u5728\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 AJP \u534f\u8bae\u901a\u8fc7 Nginx \u8bbf\u95ee Servlet\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u8bbf\u95eeservlet\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8FDCServers\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 nginx \u8bbf\u95ee servlet \u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a\u542f\u7528\u5e76\u914d\u7f6e nginx \u7684 ajp \u6a21\u5757\uff0c\u5e76\u5728\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\u4e2d\u914d\u7f6e ajp \u8fde\u63a5\u5668\u3002\u901a\u8fc7 nginx \u7684 location \u5757\u5c06 nginx \u4e0e\u5e94\u7528\u7a0b\u5e8f\u670d\u52a1\u5668\u8fde\u63a5\uff0c\u4f7f\u7528 ajp \u534f\u8bae\u8fdb\u884c\u6570\u636e\u4f20\u8f93\u3002\u5b8c\u6210\u8fd9\u4e9b\u6b65\u9aa4\u540e\uff0c\u5373\u53ef\u901a\u8fc7 nginx \u8bbf\u95ee servlet\u3002 \u5982\u4f55\u7528 Nginx \u8bbf\u95ee Servlet \u4e3a\u4e86\u7528 Nginx \u8bbf\u95ee Servlet\uff0c\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a 1. \u542f\u7528 AJP \u6a21\u5757\u4fee\u6539 Nginx \u914d\u7f6e\u6587\u4ef6\uff08.conf\uff09\uff0c\u542f\u7528 AJP \u6a21\u5757\uff1a load_module modules\/ngx_http_ajp_module.so; \u767b\u5f55\u540e\u590d\u5236 2. \u521b\u5efa AJP \u76d1\u542c\u5668 \u5728 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\u521b\u5efa\u4e00\u4e2a AJP \u76d1\u542c\u5668\uff0c\u901a\u5e38\u4f7f\u7528 8009 \u7aef\u53e3\uff1a server { listen [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-63650","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=63650"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/63650\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=63650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=63650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=63650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}