{"id":1932,"date":"2026-01-25T21:27:11","date_gmt":"2026-01-25T13:27:11","guid":{"rendered":"http:\/\/dev.puzi7.com\/?p=1919"},"modified":"2026-01-26T16:26:53","modified_gmt":"2026-01-26T08:26:53","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8nginx%e6%8a%8a%e4%b8%a4%e4%b8%aa%e5%ba%94%e7%94%a8%e5%88%86%e5%88%ab%e9%83%a8%e7%bd%b2%e5%88%b0%e4%b8%8d%e5%90%8c%e7%9a%84%e5%9f%9f%e5%90%8d","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=1932","title":{"rendered":"\u5982\u4f55\u4f7f\u7528nginx\u628a\u4e24\u4e2a\u5e94\u7528\u5206\u522b\u90e8\u7f72\u5230\u4e0d\u540c\u7684\u57df\u540d"},"content":{"rendered":"<span itemprop=\"description\">\n<p class=\"wp-block-paragraph\">\u5982\u679c\u4f60\u6709\u4e24\u4e2a\u4e0d\u540c\u7684\u5e94\u7528\uff0c\u4e00\u4e2a\u662fphp+pfm\u7684\u5e94\u7528\uff0c\u4e00\u4e2a\u662fJava+springboot\u7684\u5e94\u7528\uff0c\u4f60\u9700\u8981\u628a\u4e24\u4e2a\u5e94\u7528\u901a\u8fc7\u540c\u4e00\u4e2anginx\u7ed9\u90e8\u7f72\u5230\u4e0d\u540c\u7684\u57df\u540d\u4e0b\uff0c\u8be5\u5982\u4f55\u5904\u7406\u5462\uff1f<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7Deepseek or doubao, \u4f60\u53ef\u4ee5\u627e\u5230\u7b54\u6848\uff0c\u8fd9\u91cc\u662f\u624b\u628a\u624b\u7684\u771f\u5b9e\u5b9e\u73b0\u8fc7\u7a0b\uff0c\u5206\u4eab\u51fa\u6765\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u9996\u5148\u660e\u786e\u601d\u8def\uff0c<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u53ef\u4ee5\u901a\u8fc7nginx\u7684server\u5757\uff0c\u76d1\u542c80\u7aef\u53e3<\/li>\n\n\n\n<li>php\u7684\u5e94\u7528\uff0c\u4f7f\u7528fastcgi_pass\u8f6c\u53d1\u5e94\u7528\u5230app1.domain.com\u4e0b<\/li>\n\n\n\n<li>springboot\u5e94\u7528\uff0c\u901a\u8fc7proxy_pass\u53cd\u5411\u4ee3\u7406\u5230Java\u5e94\u7528\u76848080\u7aef\u53e3\uff0c\u4f7f\u7528app2.domain.com<\/li>\n\n\n\n<li>\u8bbe\u7f6e\u4e0d\u8981\u7684http header, \u4fdd\u8bc1\u540e\u7aef\u670d\u52a1\u80fd\u6b63\u786e\u8bc6\u522b\u5230\u5ba2\u6237\u7aef\u4fe1\u606f<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u6838\u5fc3\u914d\u7f6e\u5757for app1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>    # \u914d\u7f6e (app1.xxxx.com)\n    server {\n        listen       80;\n        server_name  app1.xxxx.com;  # \u57df\u540d\n        root         \/var\/www\/html; # \uff08\u9700\u548c\u5bb9\u5668\u5185\u8def\u5f84\u4e00\u81f4\uff09\n        index        index.php index.html index.htm;\n\n        # \u9759\u6001\u6587\u4ef6\u7f13\u5b58\n        location ~* \\.(jpg|jpeg|png|gif|ico|css|js)$ {\n            expires 30d;\n            add_header Cache-Control \"public, max-age=2592000\";\n        }\n\n        # PHP-FPM \u8f6c\u53d1\u914d\u7f6e\n        location ~ \\.php$ {\n            try_files $uri =404;\n            fastcgi_pass 127.0.0.1:9000;  # WordPress \u5bb9\u5668\u540d:\u7aef\u53e3\n            fastcgi_index index.php;\n            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\n            include fastcgi_params;\n            \n            # \u5fc5\u8981\u7684 WordPress \u73af\u5883\u53d8\u91cf\n            fastcgi_param HTTP_HOST $host;\n            fastcgi_param REMOTE_ADDR $remote_addr;\n        }\n\n        # \u901a\u7528\u8bf7\u6c42\u5904\u7406\n        location \/ {\n            try_files $uri $uri\/ \/index.php?$args;\n        }\n\n        # \u65e5\u5fd7\u914d\u7f6e\n        access_log \/var\/log\/nginx\/app1.access.log main;\n        error_log \/var\/log\/nginx\/app1.error.log;\n    }<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\"><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6838\u5fc3\u914d\u7f6efor app2:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># SpringBoot \u7ad9\u70b9\u914d\u7f6e (app2.xxxx.com)\n    server {\n        listen       80;\n        server_name  app2.xxxx.com;  # SpringBoot \u57df\u540d\n\n        # \u53cd\u5411\u4ee3\u7406\u914d\u7f6e\n        location \/ {\n            proxy_pass http:\/\/springboot-app:8080;  # SpringBoot \u5bb9\u5668\u540d:\u7aef\u53e3\n            proxy_set_header Host $host;\n            proxy_set_header X-Real-IP $remote_addr;\n            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n            proxy_set_header X-Forwarded-Proto $scheme;\n            proxy_connect_timeout 60s;\n            proxy_read_timeout 60s;\n        }\n\n        # \u65e5\u5fd7\u914d\u7f6e\n        access_log \/var\/log\/nginx\/app2.access.log main;\n        error_log \/var\/log\/nginx\/app2.error.log;\n    }\n\n\u4f46\u662f\u5982\u679c\u4f7f\u7528docker\u90e8\u7f72nginx, \u5219\u9700\u8981\u628a\u4e24\u4e2a\u5e94\u7528\u7684\u914d\u7f6e\u5171\u752880\u7aef\u53e3\uff0c\u53ef\u4ee5\u901a\u8fc7server_name\u6765\u533a\u5206\u4e0d\u540c\u7684\u57df\u540d\u548c\u5e94\u7528\u3002\n\n<strong>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff1a\u4e24\u4e2a\u57df\u540d\u7684\u89e3\u6790\u9700\u8981\u6307\u5411nginx\u6240\u5728\u670d\u52a1\u5668\u7684IP\u3002<\/strong><\/code><\/pre>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">\u5982\u679c\u4f60\u6709\u4e24\u4e2a\u4e0d\u540c\u7684\u5e94\u7528\uff0c\u4e00\u4e2a\u662fphp+pfm\u7684\u5e94\u7528\uff0c\u4e00\u4e2a\u662fJava+springboot\u7684&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=1932\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":1944,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[32,13],"tags":[60,96],"class_list":["post-1932","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-32","category-13","tag-docker","tag-nginx","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/1932","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1932"}],"version-history":[{"count":1,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/1932\/revisions"}],"predecessor-version":[{"id":1946,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/1932\/revisions\/1946"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/media\/1944"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1932"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1932"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1932"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}