{"id":124677,"date":"2026-11-19T09:48:38","date_gmt":"2026-11-19T01:48:38","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/124677.html"},"modified":"2026-11-19T09:48:38","modified_gmt":"2026-11-19T01:48:38","slug":"%e4%b8%aa%e4%ba%ba%e9%a1%b9%e7%9b%ae%e5%8f%aa%e8%b7%91%e5%9c%a8localhost%ef%bc%9f%e4%bb%8e0%e5%88%b01%e9%83%a8%e7%bd%b2%e4%b8%8a%e7%ba%bf%e5%85%a8%e6%b5%81%e7%a8%8b%ef%bc%88%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/124677.html","title":{"rendered":"\u4e2a\u4eba\u9879\u76ee\u53ea\u8dd1\u5728localhost\uff1f\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u5168\u6d41\u7a0b\uff08\u670d\u52a1\u5668+\u57df\u540d+Nginx+HTTPS\uff09"},"content":{"rendered":"<p>\u4e00\u3001\u4e3a\u4ec0\u4e48\u4f60\u7684\u9879\u76ee\u9700\u8981\u4e00\u4e2a\u516c\u7f51\u5730\u5740<\/p>\n<p>\u9762\u8bd5\u7684\u65f6\u5019\u88ab\u95ee&#034;\u4f60\u9879\u76ee\u90e8\u7f72\u5728\u54ea&#034;&#xff0c;\u56de\u7b54&#034;\u6211\u672c\u5730\u8dd1\u7684&#034;\u2014\u2014\u8fd9\u57fa\u672c\u7b49\u4e8e\u544a\u8bc9\u9762\u8bd5\u5b98&#xff1a;\u4f60\u6ca1\u78b0\u8fc7\u771f\u5b9e\u73af\u5883\u3002<\/p>\n<p>\u672c\u5730\u8dd1\u548c\u7ebf\u4e0a\u8dd1&#xff0c;\u5dee\u7684\u4e0d\u662f\u4e00\u4e2a\u516c\u7f51IP&#xff0c;\u800c\u662f\u4e00\u6574\u5957\u5de5\u7a0b\u80fd\u529b&#xff1a;\u8fdb\u7a0b\u5b88\u62a4\u3001\u53cd\u5411\u4ee3\u7406\u3001\u57df\u540d\u89e3\u6790\u3001HTTPS\u8bc1\u4e66\u3001\u9632\u706b\u5899\u7b56\u7565\u3002\u8fd9\u4e9b\u4e1c\u897f\u5728\u672c\u5730localhost\u6c38\u8fdc\u5b66\u4e0d\u5230&#xff0c;\u4f46\u53c8\u662f\u6bcf\u4e2a\u540e\u7aef\u5f00\u53d1\u7684\u5fc5\u4fee\u8bfe\u3002<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u5c31\u628a\u4e2a\u4eba\u9879\u76ee\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u7684\u5b8c\u6574\u6d41\u7a0b\u8d70\u4e00\u904d\u3002\u6211\u7528\u4e00\u4e2a Node.js &#043; MySQL \u7684\u4e2a\u4eba\u9879\u76ee\u505a\u6f14\u793a&#xff0c;\u4f46\u6d41\u7a0b\u5bf9 Python\u3001Java\u3001Go \u9879\u76ee\u5b8c\u5168\u901a\u7528\u2014\u2014\u6362\u6389\u542f\u52a8\u547d\u4ee4\u5c31\u884c\u3002<\/p>\n<p>\u5148\u8bf4\u6574\u4f53\u8def\u5f84&#xff0c;\u4e00\u5171\u516d\u6b65&#xff1a;<\/p>\n<p>\u51c6\u5907\u670d\u52a1\u5668 \u2192 \u73af\u5883\u642d\u5efa \u2192 \u4ee3\u7801\u4e0a\u4f20\u542f\u52a8 \u2192 \u57df\u540d\u89e3\u6790 \u2192 Nginx\u53cd\u4ee3 \u2192 HTTPS\u8bc1\u4e66<\/p>\n<p>\u6bcf\u4e00\u6b65\u90fd\u6709\u5751&#xff0c;\u6211\u628a\u8e29\u8fc7\u7684\u90fd\u6807\u51fa\u6765\u4e86\u3002<\/p>\n<h3>\u4e8c\u3001\u7b2c\u4e00\u6b65&#xff1a;\u51c6\u5907\u4e00\u53f0\u5e26\u516c\u7f51IP\u7684\u670d\u52a1\u5668<\/h3>\n<p>\u90e8\u7f72\u7684\u524d\u63d0\u662f\u6709\u4e00\u53f0\u516c\u7f51\u53ef\u8bbf\u95ee\u7684\u670d\u52a1\u5668\u3002\u6ca1\u6709\u516c\u7f51IP&#xff0c;\u4e00\u5207\u514d\u8c08\u3002<\/p>\n<p>\u6211\u5728\u82af\u98de\u4e91\u5f00\u4e86\u4e00\u53f0\u8bd5\u7528\u673a\u505a\u6f14\u793a&#xff0c;\u9009\u7684 Ubuntu 22.04 \u7cfb\u7edf\u3002\u8fd9\u91cc\u6709\u4e2a\u7ec6\u8282\u8981\u6ce8\u610f&#xff1a;\u4e70\u670d\u52a1\u5668\u4e00\u5b9a\u8981\u786e\u8ba4\u5e26\u516c\u7f51IP\u3002\u6709\u4e9b\u5382\u5546\u7684\u4f4e\u4ef7\u673a\u578b\u4e0d\u5e26\u516c\u7f51IP&#xff0c;\u4e70\u4e86\u624d\u53d1\u73b0\u5916\u90e8\u6839\u672c\u8bbf\u95ee\u4e0d\u4e86&#xff0c;\u8fd8\u5f97\u989d\u5916\u4e70\u5f39\u6027IP&#xff0c;\u7b97\u4e0b\u6765\u66f4\u8d35\u3002\u82af\u98de\u4e91\u7684\u673a\u5668\u662f\u81ea\u5e26\u516c\u7f51IP\u7684&#xff0c;\u7701\u4e86\u8fd9\u4e00\u6b65\u3002<\/p>\n<p>\u62ff\u5230\u670d\u52a1\u5668\u540e\u7b2c\u4e00\u4ef6\u4e8b\u4e0d\u662f\u88c5\u73af\u5883&#xff0c;\u800c\u662f\u505a\u57fa\u7840\u5b89\u5168\u914d\u7f6e&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u66f4\u65b0\u7cfb\u7edf<\/span><br \/>\n<span class=\"token function\">apt<\/span> update <span class=\"token operator\">&amp;&amp;<\/span> <span class=\"token function\">apt<\/span> upgrade <span class=\"token parameter variable\">-y<\/span><\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u90e8\u7f72\u7528\u6237&#xff0c;\u522b\u76f4\u63a5\u7528root\u8dd1\u5e94\u7528<\/span><br \/>\nadduser deploy<br \/>\n<span class=\"token function\">usermod<\/span> <span class=\"token parameter variable\">-aG<\/span> <span class=\"token function\">sudo<\/span> deploy<\/p>\n<p><span class=\"token comment\"># \u914d\u7f6eSSH\u5bc6\u94a5\u767b\u5f55&#xff08;\u6bd4\u5bc6\u7801\u5b89\u5168\u5f97\u591a&#xff09;<\/span><br \/>\n<span class=\"token comment\"># \u5728\u672c\u5730\u6267\u884c&#xff1a;<\/span><br \/>\nssh-copy-id deploy&#064;\u4f60\u7684\u516c\u7f51IP<\/p>\n<p><span class=\"token comment\"># \u7136\u540e\u7981\u7528\u5bc6\u7801\u767b\u5f55<\/span><br \/>\n<span class=\"token function\">vim<\/span> \/etc\/ssh\/sshd_config<br \/>\n<span class=\"token comment\"># PasswordAuthentication no<\/span><br \/>\nsystemctl restart sshd<\/p>\n<p>\u907f\u5751&#xff1a;\u4e91\u5382\u5546\u7684\u5b89\u5168\u7ec4\u9ed8\u8ba4\u53ef\u80fd\u53ea\u5f00\u4e8622\u7aef\u53e3\u3002\u90e8\u7f72Web\u5e94\u7528\u524d&#xff0c;\u8bb0\u5f97\u53bb\u63a7\u5236\u53f0\u628a80\u548c443\u7aef\u53e3\u653e\u884c&#xff0c;\u4e0d\u7136Nginx\u914d\u5f97\u518d\u5bf9\u4e5f\u8bbf\u95ee\u4e0d\u4e86\u3002<\/p>\n<h3>\u4e09\u3001\u7b2c\u4e8c\u6b65&#xff1a;\u642d\u5efa\u8fd0\u884c\u73af\u5883<\/h3>\n<p>\u4ee5 Node.js \u9879\u76ee\u4e3a\u4f8b&#xff0c;\u88c5 Node \u548c MySQL&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5Node.js&#xff08;\u7528nvm\u7ba1\u7406\u7248\u672c&#xff0c;\u522b\u7528apt\u88c5\u7684\u8001\u7248\u672c&#xff09;<\/span><br \/>\n<span class=\"token function\">curl<\/span> -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.39.7\/install.sh <span class=\"token operator\">|<\/span> <span class=\"token function\">bash<\/span><br \/>\n<span class=\"token builtin class-name\">source<\/span> ~\/.bashrc<br \/>\nnvm <span class=\"token function\">install<\/span> <span class=\"token number\">18<\/span><\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5MySQL<\/span><br \/>\n<span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> mysql-server <span class=\"token parameter variable\">-y<\/span><br \/>\nmysql_secure_installation   <span class=\"token comment\"># \u8bbe\u7f6eroot\u5bc6\u7801&#xff0c;\u6309\u63d0\u793a\u8d70<\/span><\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u9879\u76ee\u6570\u636e\u5e93<\/span><br \/>\nmysql <span class=\"token parameter variable\">-u<\/span> root <span class=\"token parameter variable\">-p<\/span><br \/>\nCREATE DATABASE myapp CHARACTER SET utf8mb4<span class=\"token punctuation\">;<\/span><br \/>\nCREATE <span class=\"token environment constant\">USER<\/span> <span class=\"token string\">&#039;appuser&#039;<\/span>&#064;<span class=\"token string\">&#039;localhost&#039;<\/span> IDENTIFIED BY <span class=\"token string\">&#039;\u4f60\u7684\u5bc6\u7801&#039;<\/span><span class=\"token punctuation\">;<\/span><br \/>\nGRANT ALL ON myapp.* TO <span class=\"token string\">&#039;appuser&#039;<\/span>&#064;<span class=\"token string\">&#039;localhost&#039;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>Python \u9879\u76ee\u540c\u7406&#xff1a;\u88c5 Python &#043; venv &#043; pip install\u3002Java \u9879\u76ee&#xff1a;\u88c5 JDK &#043; Maven\u3002\u6838\u5fc3\u601d\u8def\u4e00\u6837\u2014\u2014\u8fd0\u884c\u65f6\u7248\u672c\u7528\u5b98\u65b9\u63a8\u8350\u65b9\u5f0f\u88c5&#xff0c;\u522b\u7528\u7cfb\u7edf\u6e90\u91cc\u7684\u8001\u7248\u672c\u3002<\/p>\n<h3>\u56db\u3001\u7b2c\u4e09\u6b65&#xff1a;\u4e0a\u4f20\u4ee3\u7801\u5e76\u8ba9\u5b83\u5728\u540e\u53f0\u8dd1\u8d77\u6765<\/h3>\n<p>\u4ee3\u7801\u4e0a\u4f20\u6700\u7b80\u5355\u7684\u65b9\u5f0f\u662f git&#xff1a;<\/p>\n<p><span class=\"token function\">su<\/span> &#8211; deploy<br \/>\n<span class=\"token function\">git<\/span> clone https:\/\/github.com\/\u4f60\u7684\u7528\u6237\u540d\/\u4f60\u7684\u9879\u76ee.git<br \/>\n<span class=\"token builtin class-name\">cd<\/span> \u4f60\u7684\u9879\u76ee<br \/>\n<span class=\"token function\">npm<\/span> <span class=\"token function\">install<\/span><\/p>\n<p>\u7136\u540e\u662f\u5173\u952e\u4e00\u6b65&#xff1a;\u8ba9\u8fdb\u7a0b\u5728\u540e\u53f0\u6301\u7eed\u8fd0\u884c\u3002\u5f88\u591a\u4eba\u7528 npm start &amp; \u6216\u8005 nohup&#xff0c;\u4f46\u8fdb\u7a0b\u5d29\u4e86\u4e0d\u4f1a\u81ea\u52a8\u62c9\u8d77\u3002\u751f\u4ea7\u73af\u5883\u5e94\u8be5\u7528\u8fdb\u7a0b\u7ba1\u7406\u5de5\u5177&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5pm2&#xff08;Node\u9879\u76ee\u4e13\u7528\u8fdb\u7a0b\u5b88\u62a4&#xff09;<\/span><br \/>\n<span class=\"token function\">npm<\/span> <span class=\"token function\">install<\/span> <span class=\"token parameter variable\">-g<\/span> pm2<\/p>\n<p><span class=\"token comment\"># \u542f\u52a8\u5e94\u7528<\/span><br \/>\npm2 start app.js <span class=\"token parameter variable\">&#8211;name<\/span> myapp<\/p>\n<p><span class=\"token comment\"># \u8bbe\u7f6e\u5f00\u673a\u81ea\u542f<\/span><br \/>\npm2 save<br \/>\npm2 startup<\/p>\n<p>Python \u9879\u76ee\u7528 systemd \u6216 supervisor&#xff0c;\u6548\u679c\u4e00\u6837&#xff1a;\u8fdb\u7a0b\u6302\u4e86\u81ea\u52a8\u91cd\u542f\u3001\u670d\u52a1\u5668\u91cd\u542f\u540e\u81ea\u52a8\u62c9\u8d77\u3002<\/p>\n<p>\u9a8c\u8bc1\u4e00\u4e0b\u672c\u5730\u80fd\u4e0d\u80fd\u901a&#xff1a;<\/p>\n<p><span class=\"token function\">curl<\/span> http:\/\/localhost:3000<br \/>\n<span class=\"token comment\"># \u6709\u54cd\u5e94\u8bf4\u660e\u5e94\u7528\u8dd1\u8d77\u6765\u4e86<\/span><\/p>\n<p>\u4f46\u8fd9\u65f6\u5019\u5916\u7f51\u8fd8\u8bbf\u95ee\u4e0d\u5230\u2014\u2014\u56e0\u4e3a3000\u7aef\u53e3\u6ca1\u5f00&#xff0c;\u4e5f\u4e0d\u5e94\u8be5\u5f00\u3002\u771f\u6b63\u7684\u5165\u53e3\u4ea4\u7ed9Nginx\u3002<\/p>\n<h3>\u4e94\u3001\u7b2c\u56db\u6b65&#xff1a;\u57df\u540d\u89e3\u6790<\/h3>\n<p>IP\u5730\u5740\u80fd\u8bbf\u95ee&#xff0c;\u4f46\u6ca1\u4eba\u4f1a\u8bb0\u4e00\u4e32\u6570\u5b57\u3002\u4e70\u4e2a\u57df\u540d&#xff0c;\u505a\u4e00\u6761\u89e3\u6790&#xff1a;<\/p>\n<li>\u53bb\u57df\u540d\u6ce8\u518c\u5546\u4e70\u4e00\u4e2a&#xff08;.top\/.xyz \u57df\u540d\u4e00\u5e74\u5341\u51e0\u5757&#xff09;<\/li>\n<li>\u6dfb\u52a0\u4e00\u6761 A\u8bb0\u5f55&#xff1a;&#064; \u2192 \u4f60\u7684\u516c\u7f51IP<\/li>\n<li>\u518d\u52a0\u4e00\u6761 CNAME\u8bb0\u5f55&#xff1a;www \u2192 &#064;&#xff08;\u8ba9www\u524d\u7f00\u4e5f\u80fd\u8bbf\u95ee&#xff09;<\/li>\n<p>\u89e3\u6790\u751f\u6548\u4e00\u822c\u51e0\u5206\u949f\u5230\u534a\u5c0f\u65f6\u3002\u7528 ping \u4f60\u7684\u57df\u540d \u9a8c\u8bc1&#xff0c;\u8fd4\u56de\u4f60\u7684\u516c\u7f51IP\u5c31\u8bf4\u660e\u751f\u6548\u4e86\u3002<\/p>\n<p>\u907f\u5751&#xff1a;\u57df\u540d\u89e3\u6790\u751f\u6548\u524d\u522b\u6025\u7740\u914dNginx&#xff0c;\u5426\u5219\u6392\u67e5\u534a\u5929\u53d1\u73b0\u662fDNS\u6ca1\u751f\u6548&#xff0c;\u767d\u6298\u817e\u3002\u56fd\u5185\u670d\u52a1\u5668\u7528\u57df\u540d\u8fd8\u9700\u8981\u5907\u6848&#xff0c;\u5982\u679c\u4e0d\u60f3\u5907\u6848&#xff0c;\u53ef\u4ee5\u7528\u6d77\u5916\u8282\u70b9\u6216\u8005\u6682\u65f6\u7528IP&#043;\u7aef\u53e3\u8bbf\u95ee\u3002<\/p>\n<h3>\u516d\u3001\u7b2c\u4e94\u6b65&#xff1a;Nginx\u53cd\u5411\u4ee3\u7406<\/h3>\n<p>Nginx\u662f\u6574\u4e2a\u90e8\u7f72\u7684\u6838\u5fc3&#xff1a;\u63a5\u653680\u7aef\u53e3\u7684HTTP\u8bf7\u6c42&#xff0c;\u8f6c\u53d1\u7ed9\u672c\u5730\u7684\u5e94\u7528\u8fdb\u7a0b\u3002<\/p>\n<p><span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> nginx <span class=\"token parameter variable\">-y<\/span><\/p>\n<p>\u914d\u7f6e\u6587\u4ef6\u653e\u5728 \/etc\/nginx\/sites-available\/myapp&#xff1a;<\/p>\n<p>server {<br \/>\n    listen 80;<br \/>\n    server_name \u4f60\u7684\u57df\u540d.com;<\/p>\n<p>    location \/ {<br \/>\n        proxy_pass http:\/\/127.0.0.1:3000;<br \/>\n        proxy_set_header Host $host;<br \/>\n        proxy_set_header X-Real-IP $remote_addr;<br \/>\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\n    }<br \/>\n}<\/p>\n<p>\u542f\u7528\u914d\u7f6e&#xff1a;<\/p>\n<p><span class=\"token function\">ln<\/span> <span class=\"token parameter variable\">-s<\/span> \/etc\/nginx\/sites-available\/myapp \/etc\/nginx\/sites-enabled\/<br \/>\nnginx <span class=\"token parameter variable\">-t<\/span>          <span class=\"token comment\"># \u6d4b\u8bd5\u914d\u7f6e\u8bed\u6cd5<\/span><br \/>\nsystemctl reload nginx<\/p>\n<p>\u8fd9\u65f6\u5019\u6d4f\u89c8\u5668\u8bbf\u95ee http:\/\/\u4f60\u7684\u57df\u540d.com&#xff0c;\u5e94\u8be5\u5c31\u80fd\u770b\u5230\u9879\u76ee\u4e86\u3002<\/p>\n<p>\u907f\u5751&#xff1a;proxy_set_header \u8fd9\u4e09\u884c\u522b\u7701\u3002\u4e0d\u52a0\u7684\u8bdd&#xff0c;\u4f60\u7684\u5e94\u7528\u62ff\u5230\u7684\u5ba2\u6237\u7aefIP\u6c38\u8fdc\u662f127.0.0.1&#xff0c;\u505a\u9650\u6d41\u3001\u65e5\u5fd7\u7edf\u8ba1\u5168\u5e9f\u3002<\/p>\n<h3>\u4e03\u3001\u7b2c\u516d\u6b65&#xff1a;HTTPS\u8bc1\u4e66&#xff08;\u514d\u8d39&#xff09;<\/h3>\n<p>HTTP\u5728\u6d4f\u89c8\u5668\u91cc\u4f1a\u6807&#034;\u4e0d\u5b89\u5168&#034;&#xff0c;\u4e0aHTTPS\u662f\u6700\u540e\u4e00\u6b65\u3002\u7528 Let\u2019s Encrypt \u7684\u514d\u8d39\u8bc1\u4e66&#xff0c;certbot\u4e00\u952e\u641e\u5b9a&#xff1a;<\/p>\n<p><span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> certbot python3-certbot-nginx <span class=\"token parameter variable\">-y<\/span><\/p>\n<p><span class=\"token comment\"># \u81ea\u52a8\u7533\u8bf7\u8bc1\u4e66\u5e76\u4fee\u6539Nginx\u914d\u7f6e<\/span><br \/>\ncertbot <span class=\"token parameter variable\">&#8211;nginx<\/span> <span class=\"token parameter variable\">-d<\/span> \u4f60\u7684\u57df\u540d.com <span class=\"token parameter variable\">-d<\/span> www.\u4f60\u7684\u57df\u540d.com<\/p>\n<p>certbot\u4f1a\u81ea\u52a8\u5e2e\u4f60\u628aNginx\u768480\u7aef\u53e3\u91cd\u5b9a\u5411\u5230443&#xff0c;\u5e76\u914d\u4e0a\u8bc1\u4e66\u8def\u5f84\u3002\u88c5\u5b8c\u4e4b\u540e\u8bbf\u95ee https:\/\/\u4f60\u7684\u57df\u540d.com&#xff0c;\u6d4f\u89c8\u5668\u5730\u5740\u680f\u5c31\u662f\u5c0f\u9501\u4e86\u3002<\/p>\n<p>\u8bc1\u4e66\u6709\u6548\u671f90\u5929&#xff0c;certbot\u88c5\u5b8c\u4f1a\u81ea\u52a8\u52a0\u5b9a\u65f6\u7eed\u671f\u4efb\u52a1&#xff0c;\u4e0d\u7528\u64cd\u5fc3&#xff1a;<\/p>\n<p><span class=\"token comment\"># \u9a8c\u8bc1\u81ea\u52a8\u7eed\u671f<\/span><br \/>\ncertbot renew &#8211;dry-run<\/p>\n<h3>\u516b\u3001\u5168\u6d41\u7a0b\u907f\u5751\u6e05\u5355<\/h3>\n<p>\u628a\u8e29\u8fc7\u7684\u5751\u6c47\u603b\u4e00\u4e0b&#xff0c;\u5bf9\u7167\u68c0\u67e5&#xff1a;<\/p>\n<table>\n<tr>\u5751\u73b0\u8c61\u89e3\u51b3<\/tr>\n<tbody>\n<tr>\n<td>\u5b89\u5168\u7ec4\u6ca1\u5f00\u7aef\u53e3<\/td>\n<td>\u6d4f\u89c8\u5668\u4e00\u76f4\u8f6c\u5708<\/td>\n<td>\u63a7\u5236\u53f0\u653e\u884c80\/443<\/td>\n<\/tr>\n<tr>\n<td>\u7528root\u8dd1\u5e94\u7528<\/td>\n<td>\u88ab\u5165\u4fb5\u540e\u5168\u76d8\u6ca6\u9677<\/td>\n<td>\u5efadeploy\u7528\u6237&#043;\u5bc6\u94a5\u767b\u5f55<\/td>\n<\/tr>\n<tr>\n<td>\u8fdb\u7a0b\u6ca1\u5b88\u62a4<\/td>\n<td>SSH\u65ad\u5f00\u5e94\u7528\u5c31\u505c<\/td>\n<td>pm2\/systemd\u5b88\u62a4<\/td>\n<\/tr>\n<tr>\n<td>\u5fd8\u52a0proxy_set_header<\/td>\n<td>\u5e94\u7528\u62ff\u5230\u7684IP\u5168\u662f127.0.0.1<\/td>\n<td>Nginx\u914d\u7f6e\u52a0\u4e09\u884cheader<\/td>\n<\/tr>\n<tr>\n<td>\u57df\u540d\u6ca1\u5907\u6848<\/td>\n<td>\u56fd\u5185\u670d\u52a1\u5668\u57df\u540d\u6253\u4e0d\u5f00<\/td>\n<td>\u5907\u6848\u6216\u7528IP\u4e34\u65f6\u8bbf\u95ee<\/td>\n<\/tr>\n<tr>\n<td>\u8bc1\u4e66\u8fc7\u671f<\/td>\n<td>\u6d4f\u89c8\u5668\u7ea2\u8272\u8b66\u544a<\/td>\n<td>certbot\u81ea\u52a8\u7eed\u671f<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>\u4e5d\u3001\u5199\u5728\u6700\u540e<\/h3>\n<p>\u6574\u4e2a\u6d41\u7a0b\u8d70\u4e0b\u6765&#xff0c;\u4f60\u4f1a\u53d1\u73b0&#034;\u90e8\u7f72\u4e0a\u7ebf&#034;\u672c\u8eab\u4e0d\u96be&#xff0c;\u96be\u7684\u662f\u628a\u6bcf\u4e00\u6b65\u7684\u5751\u90fd\u8e29\u660e\u767d\u3002\u8fd9\u5957\u6d41\u7a0b\u8dd1\u901a\u4e00\u6b21&#xff0c;\u4ee5\u540e\u4efb\u4f55\u9879\u76ee\u4e0a\u7ebf\u90fd\u662f\u540c\u4e00\u4e2a\u5957\u8def&#xff1a;\u670d\u52a1\u5668\u2192\u73af\u5883\u2192\u5b88\u62a4\u2192\u57df\u540d\u2192\u53cd\u4ee3\u2192HTTPS\u3002<\/p>\n<p>\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u4e00\u53f0\u5e26\u516c\u7f51IP\u7684\u670d\u52a1\u5668\u6765\u7ec3\u624b&#xff0c;\u53ef\u4ee5\u5148\u5728\u82af\u98de\u4e911\u5143\u5f00\u901a\u4e00\u53f0\u8bd5\u7528\u673a&#xff0c;\u628a\u8fd9\u5957\u6d41\u7a0b\u5b8c\u6574\u8dd1\u4e00\u904d\u3002\u4eceSSH\u8fde\u63a5\u5230HTTPS\u5c0f\u9501\u4eae\u8d77\u6765&#xff0c;\u5168\u7a0b\u4e0d\u5230\u4e00\u5c0f\u65f6&#xff0c;\u4f46\u7b80\u5386\u4e0a&#034;\u719f\u6089\u9879\u76ee\u90e8\u7f72&#034;\u8fd9\u53e5\u8bdd\u5c31\u771f\u7684\u7acb\u5f97\u4f4f\u4e86\u3002<\/p>\n<p>            <span id=\"quality-guide-article-end\" aria-hidden=\"true\" style=\"display:block;height:1px;margin-bottom:-1px\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u4e3a\u4ec0\u4e48\u4f60\u7684\u9879\u76ee\u9700\u8981\u4e00\u4e2a\u516c\u7f51\u5730\u5740<br \/>\n\u9762\u8bd5\u7684\u65f6\u5019\u88ab\u95ee\\&#8221;\u4f60\u9879\u76ee\u90e8\u7f72\u5728\u54ea\\&#8221;&#xff0c;\u56de\u7b54\\&#8221;\u6211\u672c\u5730\u8dd1\u7684\\&#8221;\u2014\u2014\u8fd9\u57fa\u672c\u7b49\u4e8e\u544a\u8bc9\u9762\u8bd5\u5b98&#xff1a;\u4f60\u6ca1\u78b0\u8fc7\u771f\u5b9e\u73af\u5883\u3002<br \/>\n\u672c\u5730\u8dd1\u548c\u7ebf\u4e0a\u8dd1&#xff0c;\u5dee\u7684\u4e0d\u662f\u4e00\u4e2a\u516c\u7f51IP&#xff0c;\u800c\u662f\u4e00\u6574\u5957\u5de5\u7a0b\u80fd\u529b&#xff1a;\u8fdb\u7a0b\u5b88\u62a4\u3001\u53cd\u5411\u4ee3\u7406\u3001\u57df\u540d\u89e3\u6790\u3001HTTPS\u8bc1\u4e66\u3001\u9632\u706b\u5899\u7b56\u7565\u3002\u8fd9\u4e9b\u4e1c\u897f\u5728\u672c\u5730localhost\u6c38\u8fdc\u5b66\u4e0d\u5230&#xff0c;\u4f46\u53c8\u662f\u6bcf\u4e2a\u540e\u7aef\u5f00\u53d1\u7684\u5fc5\u4fee\u8bfe\u3002<br \/>\n\u8fd9\u7bc7\u6587\u7ae0\u5c31\u628a\u4e2a\u4eba\u9879\u76ee\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u7684\u5b8c\u6574\u6d41\u7a0b\u8d70\u4e00\u904d\u3002\u6211\u7528\u4e00\u4e2a Node<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[117,43,44],"topic":[],"class_list":["post-124677","post","type-post","status-publish","format-standard","hentry","category-server","tag-nginx","tag-43","tag-44"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4e2a\u4eba\u9879\u76ee\u53ea\u8dd1\u5728localhost\uff1f\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u5168\u6d41\u7a0b\uff08\u670d\u52a1\u5668+\u57df\u540d+Nginx+HTTPS\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/124677.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4e2a\u4eba\u9879\u76ee\u53ea\u8dd1\u5728localhost\uff1f\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u5168\u6d41\u7a0b\uff08\u670d\u52a1\u5668+\u57df\u540d+Nginx+HTTPS\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4e00\u3001\u4e3a\u4ec0\u4e48\u4f60\u7684\u9879\u76ee\u9700\u8981\u4e00\u4e2a\u516c\u7f51\u5730\u5740 \u9762\u8bd5\u7684\u65f6\u5019\u88ab\u95ee&quot;\u4f60\u9879\u76ee\u90e8\u7f72\u5728\u54ea&quot;&#xff0c;\u56de\u7b54&quot;\u6211\u672c\u5730\u8dd1\u7684&quot;\u2014\u2014\u8fd9\u57fa\u672c\u7b49\u4e8e\u544a\u8bc9\u9762\u8bd5\u5b98&#xff1a;\u4f60\u6ca1\u78b0\u8fc7\u771f\u5b9e\u73af\u5883\u3002 \u672c\u5730\u8dd1\u548c\u7ebf\u4e0a\u8dd1&#xff0c;\u5dee\u7684\u4e0d\u662f\u4e00\u4e2a\u516c\u7f51IP&#xff0c;\u800c\u662f\u4e00\u6574\u5957\u5de5\u7a0b\u80fd\u529b&#xff1a;\u8fdb\u7a0b\u5b88\u62a4\u3001\u53cd\u5411\u4ee3\u7406\u3001\u57df\u540d\u89e3\u6790\u3001HTTPS\u8bc1\u4e66\u3001\u9632\u706b\u5899\u7b56\u7565\u3002\u8fd9\u4e9b\u4e1c\u897f\u5728\u672c\u5730localhost\u6c38\u8fdc\u5b66\u4e0d\u5230&#xff0c;\u4f46\u53c8\u662f\u6bcf\u4e2a\u540e\u7aef\u5f00\u53d1\u7684\u5fc5\u4fee\u8bfe\u3002 \u8fd9\u7bc7\u6587\u7ae0\u5c31\u628a\u4e2a\u4eba\u9879\u76ee\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u7684\u5b8c\u6574\u6d41\u7a0b\u8d70\u4e00\u904d\u3002\u6211\u7528\u4e00\u4e2a Node\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/124677.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-11-19T01:48:38+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/124677.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/124677.html\",\"name\":\"\u4e2a\u4eba\u9879\u76ee\u53ea\u8dd1\u5728localhost\uff1f\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u5168\u6d41\u7a0b\uff08\u670d\u52a1\u5668+\u57df\u540d+Nginx+HTTPS\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-11-19T01:48:38+00:00\",\"dateModified\":\"2026-11-19T01:48:38+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/124677.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/124677.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/124677.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4e2a\u4eba\u9879\u76ee\u53ea\u8dd1\u5728localhost\uff1f\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u5168\u6d41\u7a0b\uff08\u670d\u52a1\u5668+\u57df\u540d+Nginx+HTTPS\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4e2a\u4eba\u9879\u76ee\u53ea\u8dd1\u5728localhost\uff1f\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u5168\u6d41\u7a0b\uff08\u670d\u52a1\u5668+\u57df\u540d+Nginx+HTTPS\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/124677.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4e2a\u4eba\u9879\u76ee\u53ea\u8dd1\u5728localhost\uff1f\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u5168\u6d41\u7a0b\uff08\u670d\u52a1\u5668+\u57df\u540d+Nginx+HTTPS\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4e00\u3001\u4e3a\u4ec0\u4e48\u4f60\u7684\u9879\u76ee\u9700\u8981\u4e00\u4e2a\u516c\u7f51\u5730\u5740 \u9762\u8bd5\u7684\u65f6\u5019\u88ab\u95ee\"\u4f60\u9879\u76ee\u90e8\u7f72\u5728\u54ea\"&#xff0c;\u56de\u7b54\"\u6211\u672c\u5730\u8dd1\u7684\"\u2014\u2014\u8fd9\u57fa\u672c\u7b49\u4e8e\u544a\u8bc9\u9762\u8bd5\u5b98&#xff1a;\u4f60\u6ca1\u78b0\u8fc7\u771f\u5b9e\u73af\u5883\u3002 \u672c\u5730\u8dd1\u548c\u7ebf\u4e0a\u8dd1&#xff0c;\u5dee\u7684\u4e0d\u662f\u4e00\u4e2a\u516c\u7f51IP&#xff0c;\u800c\u662f\u4e00\u6574\u5957\u5de5\u7a0b\u80fd\u529b&#xff1a;\u8fdb\u7a0b\u5b88\u62a4\u3001\u53cd\u5411\u4ee3\u7406\u3001\u57df\u540d\u89e3\u6790\u3001HTTPS\u8bc1\u4e66\u3001\u9632\u706b\u5899\u7b56\u7565\u3002\u8fd9\u4e9b\u4e1c\u897f\u5728\u672c\u5730localhost\u6c38\u8fdc\u5b66\u4e0d\u5230&#xff0c;\u4f46\u53c8\u662f\u6bcf\u4e2a\u540e\u7aef\u5f00\u53d1\u7684\u5fc5\u4fee\u8bfe\u3002 \u8fd9\u7bc7\u6587\u7ae0\u5c31\u628a\u4e2a\u4eba\u9879\u76ee\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u7684\u5b8c\u6574\u6d41\u7a0b\u8d70\u4e00\u904d\u3002\u6211\u7528\u4e00\u4e2a Node","og_url":"https:\/\/www.wsisp.com\/helps\/124677.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-11-19T01:48:38+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/124677.html","url":"https:\/\/www.wsisp.com\/helps\/124677.html","name":"\u4e2a\u4eba\u9879\u76ee\u53ea\u8dd1\u5728localhost\uff1f\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u5168\u6d41\u7a0b\uff08\u670d\u52a1\u5668+\u57df\u540d+Nginx+HTTPS\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-11-19T01:48:38+00:00","dateModified":"2026-11-19T01:48:38+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/124677.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/124677.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/124677.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4e2a\u4eba\u9879\u76ee\u53ea\u8dd1\u5728localhost\uff1f\u4ece0\u52301\u90e8\u7f72\u4e0a\u7ebf\u5168\u6d41\u7a0b\uff08\u670d\u52a1\u5668+\u57df\u540d+Nginx+HTTPS\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/124677","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=124677"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/124677\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=124677"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=124677"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=124677"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=124677"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}