{"id":18029,"date":"2024-11-18T11:51:04","date_gmt":"2024-11-18T03:51:04","guid":{"rendered":"https:\/\/fwq.ai\/blog\/18029\/"},"modified":"2024-11-18T11:51:04","modified_gmt":"2024-11-18T03:51:04","slug":"%e6%80%8e%e4%b9%88%e6%8a%8anginx%e8%ae%bf%e9%97%ae%e5%9c%b0%e5%9d%80%e8%ae%be%e7%bd%ae%e6%88%90%e6%9c%8d%e5%8a%a1%e5%99%a8ip","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/18029\/","title":{"rendered":"\u600e\u4e48\u628anginx\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u6210\u670d\u52a1\u5668ip"},"content":{"rendered":"<blockquote><p>\n  \u8981\u5728 nginx \u4e2d\u5c06\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u4e3a\u670d\u52a1\u5668 ip\uff0c\u8bf7\uff1a\u914d\u7f6e\u670d\u52a1\u5668\u5757\uff0c\u8bbe\u7f6e\u76d1\u542c\u5730\u5740\uff08\u5982\uff1alisten 192.168.1.10:80\uff09\u8bbe\u7f6e\u670d\u52a1\u5668\u540d\u79f0\uff08\u5982\uff1aserver_name example.com www.example.com\uff09\uff0c\u6216\u5c06\u5176\u7559\u7a7a\u4ee5\u8bbf\u95ee\u670d\u52a1\u5668 ip\u4fdd\u5b58\u5e76\u91cd\u65b0\u52a0\u8f7d nginx \u4ee5\u5e94\u7528\u66f4\u6539\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/27\/2024052719182143453.jpg\" class=\"aligncenter\" title=\"\u600e\u4e48\u628anginx\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u6210\u670d\u52a1\u5668ip\u63d2\u56fe\" alt=\"\u600e\u4e48\u628anginx\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u6210\u670d\u52a1\u5668ip\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 Nginx \u4e2d\u5c06\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u4e3a\u670d\u52a1\u5668 IP<\/strong><\/p>\n<p>\u5728 Nginx \u4e2d\u5c06\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u4e3a\u670d\u52a1\u5668 IP \u7684\u6b65\u9aa4\uff1a<\/p>\n<p><strong>1. \u914d\u7f6e\u670d\u52a1\u5668\u5757<\/strong><\/p>\n<p>\u5728 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u6216\u521b\u5efa\u8981\u914d\u7f6e\u7684\u670d\u52a1\u5668\u5757\u3002\u670d\u52a1\u5668\u5757\u901a\u5e38\u4f4d\u4e8e &#8220;sites-enabled&#8221; \u76ee\u5f55\u4e0b\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002<\/p>\n<pre>server {\n    ...\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>2. \u8bbe\u7f6e\u76d1\u542c\u5730\u5740<\/strong><\/p>\n<p>\u5728\u670d\u52a1\u5668\u5757\u4e2d\uff0c\u6dfb\u52a0 &#8220;listen&#8221; \u6307\u4ee4\u4ee5\u6307\u5b9a Nginx \u76d1\u542c\u7684 IP \u5730\u5740\u548c\u7aef\u53e3\u3002<\/p>\n<pre>server {\n    listen &lt;ip-address&gt;:&lt;port&gt;;\n    ...\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff0c \u662f\u670d\u52a1\u5668\u7684 IP \u5730\u5740\uff0c \u662f\u60a8\u5e0c\u671b\u7528\u4e8e\u8bbf\u95ee\u7f51\u7ad9\u7684\u7aef\u53e3\uff08\u901a\u5e38\u4e3a 80\uff09\u3002\u4f8b\u5982\uff0c\u8981\u8ba9 Nginx \u5728\u670d\u52a1\u5668 IP &#8220;192.168.1.10&#8221; \u4e0a\u7684 80 \u7aef\u53e3\u76d1\u542c\uff1a <\/p>\n<pre>server {\n    listen 192.168.1.10:80;\n    ...\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>3. \u8bbe\u7f6e\u670d\u52a1\u5668\u540d\u79f0<\/strong><\/p>\n<p>\u5728\u670d\u52a1\u5668\u5757\u4e2d\uff0c\u6dfb\u52a0 &#8220;server_name&#8221; \u6307\u4ee4\u4ee5\u6307\u5b9a\u670d\u52a1\u5668\u54cd\u5e94\u7684\u57df\u540d\u6216 IP \u5730\u5740\u3002<\/p>\n<pre>server {\n    listen &lt;ip-address&gt;:&lt;port&gt;;\n    server_name example.com www.example.com;\n    ...\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5982\u679c\u8bbf\u95ee\u5730\u5740\u4e0d\u662f\u57df\u540d\uff0c\u8bf7\u5c06 &#8220;server_name&#8221; \u8bbe\u7f6e\u4e3a\u7a7a\u3002<\/p>\n<p><strong>4. \u4fdd\u5b58\u5e76\u91cd\u65b0\u52a0\u8f7d Nginx<\/strong><\/p>\n<p>\u4fdd\u5b58 Nginx \u914d\u7f6e\u6587\u4ef6\u5e76\u91cd\u65b0\u52a0\u8f7d Nginx \u4ee5\u5e94\u7528\u66f4\u6539\u3002<\/p>\n<pre>sudo systemctl reload nginx<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u73b0\u5728\uff0c\u5f53\u60a8\u8bbf\u95ee\u5728 &#8220;listen&#8221; \u6307\u4ee4\u4e2d\u6307\u5b9a\u7684 IP \u5730\u5740\u548c\u7aef\u53e3\u65f6\uff0cNginx \u5c06\u4f1a\u54cd\u5e94\u5e76\u663e\u793a\u4e3a\u670d\u52a1\u5668 IP \u8bbf\u95ee\u7684\u7f51\u7ad9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u628a\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u6210\u670d\u52a1\u5668ip\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8981\u5728 nginx \u4e2d\u5c06\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u4e3a\u670d\u52a1\u5668 ip\uff0c\u8bf7\uff1a\u914d\u7f6e\u670d\u52a1\u5668\u5757\uff0c\u8bbe\u7f6e\u76d1\u542c\u5730\u5740\uff08\u5982\uff1alisten 192.168.1.10:80\uff09\u8bbe\u7f6e\u670d\u52a1\u5668\u540d\u79f0\uff08\u5982\uff1aserver_name example.com www.example.com\uff09\uff0c\u6216\u5c06\u5176\u7559\u7a7a\u4ee5\u8bbf\u95ee\u670d\u52a1\u5668 ip\u4fdd\u5b58\u5e76\u91cd\u65b0\u52a0\u8f7d nginx \u4ee5\u5e94\u7528\u66f4\u6539 \u5982\u4f55\u5728 Nginx \u4e2d\u5c06\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u4e3a\u670d\u52a1\u5668 IP \u5728 Nginx \u4e2d\u5c06\u8bbf\u95ee\u5730\u5740\u8bbe\u7f6e\u4e3a\u670d\u52a1\u5668 IP \u7684\u6b65\u9aa4\uff1a 1. \u914d\u7f6e\u670d\u52a1\u5668\u5757 \u5728 Nginx \u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u6216\u521b\u5efa\u8981\u914d\u7f6e\u7684\u670d\u52a1\u5668\u5757\u3002\u670d\u52a1\u5668\u5757\u901a\u5e38\u4f4d\u4e8e &#8220;sites-enabled&#8221; \u76ee\u5f55\u4e0b\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002 server { &#8230; } \u767b\u5f55\u540e\u590d\u5236 2. \u8bbe\u7f6e\u76d1\u542c\u5730\u5740 \u5728\u670d\u52a1\u5668\u5757\u4e2d\uff0c\u6dfb\u52a0 &#8220;listen&#8221; \u6307\u4ee4\u4ee5\u6307\u5b9a Nginx \u76d1\u542c\u7684 IP \u5730\u5740\u548c\u7aef\u53e3\u3002 server { listen &lt;ip-address&gt;:&lt;port&gt;; &#8230; } \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff0c \u662f\u670d\u52a1\u5668\u7684 IP \u5730\u5740\uff0c \u662f\u60a8\u5e0c\u671b\u7528\u4e8e\u8bbf\u95ee\u7f51\u7ad9\u7684\u7aef\u53e3\uff08\u901a\u5e38\u4e3a 80\uff09\u3002\u4f8b\u5982\uff0c\u8981\u8ba9 Nginx \u5728\u670d\u52a1\u5668 [&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-18029","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18029","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=18029"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/18029\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=18029"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=18029"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=18029"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}