{"id":9079,"date":"2025-04-18T17:08:26","date_gmt":"2025-04-18T09:08:26","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/9079.html"},"modified":"2025-04-18T17:08:26","modified_gmt":"2025-04-18T09:08:26","slug":"nginx-%e6%90%ad%e5%bb%ba-ipv6-%ef%bc%9e-ipv4-%e5%8f%8d%e5%90%91%e4%bb%a3%e7%90%86%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/9079.html","title":{"rendered":"nginx \u642d\u5efa IPv6 -\uff1e IPv4 \u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668"},"content":{"rendered":"<h3>\u80cc\u666f<\/h3>\n<p>\u5728\u5b9e\u9645\u751f\u4ea7\u8fc7\u7a0b\u4e2d&#xff0c;\u7531\u4e8e\u5404\u79cd\u539f\u56e0&#xff0c;\u6211\u4eec\u7684\u5728\u7ebf\u670d\u52a1\u642d\u5efa\u5728\u706b\u5c71\u4e91\u670d\u52a1\u5668\u4e0a&#xff0c;\u4f7f\u7528\u706b\u5c71\u4e91\u5305\u62ec ECS\u3001CLB\u3001PLB \u7b49\u7ec4\u4ef6\u8fdb\u884c\u7f51\u7edc\u901a\u4fe1&#xff0c;\u5e76\u4e14\u901a\u8fc7\u4e13\u7ebf\u63a5\u53d7\u6765\u81ea\u67d0\u516c\u53f8\u5185\u90e8\u6d41\u91cf\u3002\u4f46\u662f\u5728\u5927\u6982 22~23 \u5e74&#xff0c;\u67d0\u516c\u53f8\u8981\u628a\u6240\u6709\u7f51\u7edc\u6d41\u91cf\u53d8\u4e3a IPv6 \u5f80\u4e0b\u53d1&#xff0c;\u706b\u5c71\u4e91\u7684 CLB \u548c PLB \u8fd8\u4e0d\u652f\u6301 IPv6&#xff0c;\u90a3\u6211\u4eec\u5c31\u9762\u4e34\u7740\u65ad\u6d41\u7684\u98ce\u9669\u3002\u7ecf\u8c03\u7814\u548c\u5b66\u4e60&#xff0c;\u4e86\u89e3\u5230\u53ef\u4ee5\u901a\u8fc7 nginx \u6765\u642d\u5efa\u4e00\u4e2a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u91cc&#xff0c;\u628a IPv6 \u7684\u6d41\u91cf\u8f6c\u6210 IPv4 \u5f80\u4e0b\u53d1&#xff0c;\u8fd9\u6837\u5c31\u89e3\u51b3\u4e86\u6211\u4eec\u7684\u95ee\u9898\u3002\u672c\u7bc7\u6587\u7ae0\u4e5f\u662f\u8bb0\u5f55\u4e00\u4e0b\u5f53\u65f6\u7684\u642d\u5efa\u8fc7\u7a0b\u548c\u6b65\u9aa4&#xff0c;\u4ee5\u53ca\u8e29\u8fc7\u7684\u5751\u3002<\/p>\n<h3>\u642d\u5efa\u6b65\u9aa4<\/h3>\n<li>\u5728 nginx \u5b98\u7f51\u4e0b\u8f7d\u7a33\u5b9a\u7248\u672c\u7684 nginx \u5305\u3002https:\/\/nginx.org\/en\/download.html<\/li>\n<li>\u89e3\u538b\u3002<\/li>\n<p><span class=\"token function\">sudo<\/span> <span class=\"token function\">tar<\/span> <span class=\"token parameter variable\">-zxvf<\/span> nginx-1.18.0.tar.gz<\/p>\n<li>\u8fdb\u5165 nginx \u76ee\u5f55\u5e76\u8fdb\u884c\u5b89\u88c5\u3002<\/li>\n<p><span class=\"token builtin class-name\">cd<\/span> nginx-1.18.0<br \/>\n<span class=\"token function\">apt-get<\/span> update<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt-get<\/span> <span class=\"token function\">install<\/span> libpcre3-dev<br \/>\n.\/configure <span class=\"token parameter variable\">&#8211;prefix<\/span><span class=\"token operator\">&#061;<\/span>\/usr\/local\/nginx &#8211;with-stream<br \/>\n<span class=\"token function\">make<\/span> <span class=\"token comment\"># \u7f16\u8bd1<\/span><br \/>\n<span class=\"token function\">make<\/span> <span class=\"token function\">install<\/span> <span class=\"token comment\"># \u5b89\u88c5<\/span><\/p>\n<li>\u4fee\u6539 nginx \u914d\u7f6e\u4fe1\u606f\u3002<\/li>\n<p><span class=\"token builtin class-name\">cd<\/span> <span class=\"token punctuation\">..<\/span>\/conf<br \/>\n<span class=\"token function\">cp<\/span> nginx.conf nginx.conf.bak<br \/>\n<span class=\"token function\">vim<\/span> nginx.conf<\/p>\n<p><span class=\"token comment\"># \u8bbe\u7f6e nginx \u8fd0\u884c\u7684\u7528\u6237&#xff08;\u901a\u5e38\u4e3a nobody \u6216 www-data&#xff09;<\/span><br \/>\n<span class=\"token comment\"># user  nobody;<\/span><\/p>\n<p><span class=\"token comment\"># \u6307\u5b9a nginx \u7684\u5de5\u4f5c\u8fdb\u7a0b\u6570\u91cf&#xff0c;auto \u8868\u793a\u81ea\u52a8\u6839\u636e CPU \u6838\u5fc3\u6570\u8c03\u6574<\/span><br \/>\nworker_processes  auto<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\"># \u8bbe\u5b9a\u9519\u8bef\u65e5\u5fd7\u8def\u5f84\u53ca\u65e5\u5fd7\u7ea7\u522b&#xff08;\u9ed8\u8ba4\u662f error&#xff0c;\u53ef\u9009 notice\u3001info \u7b49&#xff09;<\/span><br \/>\n<span class=\"token comment\">#error_log  logs\/error.log;<\/span><br \/>\n<span class=\"token comment\">#error_log  logs\/error.log  notice;<\/span><br \/>\n<span class=\"token comment\">#error_log  logs\/error.log  info;<\/span><\/p>\n<p><span class=\"token comment\"># \u6307\u5b9a nginx \u8fd0\u884c\u65f6\u7684 PID \u6587\u4ef6\u5b58\u653e\u8def\u5f84<\/span><br \/>\n<span class=\"token comment\"># pid        logs\/nginx.pid;<\/span><\/p>\n<p>events <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\"># \u6bcf\u4e2a worker \u8fdb\u7a0b\u5141\u8bb8\u7684\u6700\u5927\u5e76\u53d1\u8fde\u63a5\u6570<\/span><br \/>\n    worker_connections  <span class=\"token number\">65535<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>http <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\"># \u5f15\u5165 MIME \u7c7b\u578b\u914d\u7f6e\u6587\u4ef6&#xff0c;\u786e\u4fdd nginx \u8bc6\u522b\u5404\u79cd\u6587\u4ef6\u7c7b\u578b<\/span><br \/>\n    include       mime.types<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u8bbe\u7f6e\u9ed8\u8ba4\u7684 MIME \u7c7b\u578b&#xff0c;\u907f\u514d\u672a\u8bc6\u522b\u7684\u6587\u4ef6\u53d8\u6210\u7eaf\u6587\u672c<\/span><br \/>\n    default_type  application\/octet-stream<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u5b9a\u4e49\u65e5\u5fd7\u683c\u5f0f&#xff08;$remote_addr&#xff1a;\u5ba2\u6237\u7aef IP&#xff0c;$request&#xff1a;\u8bf7\u6c42\u5185\u5bb9&#xff0c;$status&#xff1a;\u72b6\u6001\u7801\u7b49&#xff09;<\/span><br \/>\n    <span class=\"token comment\"># log_format  main  &#039;$remote_addr &#8211; $remote_user [$time_local] &#034;$request&#034; &#039;<\/span><br \/>\n    <span class=\"token comment\">#                  &#039;$status $body_bytes_sent &#034;$http_referer&#034; &#039;<\/span><br \/>\n    <span class=\"token comment\">#                  &#039;&#034;$http_user_agent&#034; &#034;$http_x_forwarded_for&#034;&#039;;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u6307\u5b9a\u8bbf\u95ee\u65e5\u5fd7\u5b58\u50a8\u8def\u5f84\u53ca\u4f7f\u7528\u7684\u65e5\u5fd7\u683c\u5f0f<\/span><br \/>\n    <span class=\"token comment\"># access_log  logs\/access.log  main;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u542f\u7528 sendfile \u4ee5\u4f18\u5316\u6587\u4ef6\u4f20\u8f93\u6027\u80fd<\/span><br \/>\n    sendfile        on<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u7ed3\u5408 sendfile \u4f7f\u7528&#xff0c;\u51cf\u5c11 TCP \u53d1\u9001\u5ef6\u8fdf&#xff08;\u4f46\u53ef\u80fd\u5f71\u54cd\u5c0f\u6570\u636e\u5305\u4f20\u8f93&#xff09;<\/span><br \/>\n    <span class=\"token comment\"># tcp_nopush     on;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u8bbe\u5b9a\u8fde\u63a5\u7684 Keep-Alive \u8d85\u65f6\u65f6\u95f4&#xff08;0 \u4ee3\u8868\u5173\u95ed keep-alive&#xff09;<\/span><br \/>\n    <span class=\"token comment\"># keepalive_timeout  0;<\/span><br \/>\n    keepalive_timeout  120s<span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u8bbe\u5b9a\u4e00\u4e2a\u8fde\u63a5\u5185\u6700\u5927\u8bf7\u6c42\u6570&#xff0c;\u907f\u514d\u957f\u8fde\u63a5\u5360\u7528\u8fc7\u591a\u8d44\u6e90<\/span><br \/>\n    keepalive_requests <span class=\"token number\">100000<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>    <span class=\"token comment\"># \u542f\u7528 gzip \u538b\u7f29&#xff0c;\u63d0\u9ad8\u4f20\u8f93\u6548\u7387&#xff08;\u9ed8\u8ba4\u5173\u95ed&#xff09;<\/span><br \/>\n    <span class=\"token comment\"># gzip  on;<\/span><\/p>\n<p>    server <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\"># \u76d1\u542c IPv4 80 \u7aef\u53e3&#xff08;\u9ed8\u8ba4\u60c5\u51b5\u4e0b&#xff0c;\u8fd9\u884c\u88ab\u6ce8\u91ca&#xff09;<\/span><br \/>\n        <span class=\"token comment\"># listen 80;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u76d1\u542c IPv4 443 \u7aef\u53e3&#xff08;\u7528\u4e8e HTTPS&#xff0c;\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u88ab\u6ce8\u91ca&#xff09;<\/span><br \/>\n        <span class=\"token comment\"># listen 443;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u76d1\u542c IPv6 80 \u7aef\u53e3&#xff08;\u9ed8\u8ba4\u542f\u7528&#xff09;<\/span><br \/>\n        listen <span class=\"token punctuation\">[<\/span>::<span class=\"token punctuation\">]<\/span>:80<span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u670d\u52a1\u5668\u7684\u57df\u540d&#xff08;\u9700\u8981\u4fee\u6539\u4e3a\u4f60\u7684\u5b9e\u9645\u57df\u540d&#xff09;<\/span><br \/>\n        server_name aaa.bbb.ccc<span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u8bbf\u95ee\u65e5\u5fd7\u5b58\u50a8\u8def\u5f84<\/span><br \/>\n        access_log  \/www\/wwwlogs\/aaa.bbb.ccc.log<span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># \u9519\u8bef\u65e5\u5fd7\u5b58\u50a8\u8def\u5f84<\/span><br \/>\n        error_log  \/www\/wwwlogs\/aaa.bbb.ccc.error.log<span class=\"token punctuation\">;<\/span><\/p>\n<p>        location \/ <span class=\"token punctuation\">{<\/span><br \/>\n            <span class=\"token comment\"># \u4ee3\u7406\u8bf7\u6c42\u4f7f\u7528 HTTP\/1.1&#xff08;\u907f\u514d HTTP\/1.0 \u9020\u6210\u7684\u8fde\u63a5\u590d\u7528\u95ee\u9898&#xff09;<\/span><br \/>\n            proxy_http_version <span class=\"token number\">1.1<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>            <span class=\"token comment\"># \u4ee3\u7406\u8bf7\u6c42\u65f6\u8bbe\u7f6e Host \u5934&#xff0c;\u9632\u6b62\u540e\u7aef\u670d\u52a1\u56e0 Host \u53d8\u66f4\u5f02\u5e38<\/span><br \/>\n            proxy_set_header Host aaa.bbb.ccc:80<span class=\"token punctuation\">;<\/span> <\/p>\n<p>            <span class=\"token comment\"># \u4f20\u9012\u5ba2\u6237\u7aef\u771f\u5b9e IP<\/span><br \/>\n            proxy_set_header X-Real-IP <span class=\"token variable\">$remote_addr<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>            <span class=\"token comment\"># \u6e05\u7a7a Connection \u5934&#xff0c;\u9632\u6b62 nginx \u8bef\u5904\u7406\u957f\u8fde\u63a5<\/span><br \/>\n            proxy_set_header Connection <span class=\"token string\">&#034;&#034;<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>            <span class=\"token comment\"># \u4f20\u9012\u5ba2\u6237\u7aef\u8fdc\u7a0b\u5730\u5740&#xff08;\u7528\u4e8e\u540e\u7aef\u65e5\u5fd7\u5206\u6790&#xff09;<\/span><br \/>\n            proxy_set_header REMOTE-HOST <span class=\"token variable\">$remote_addr<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>            <span class=\"token comment\"># \u4f20\u9012 X-Forwarded-For&#xff0c;\u8bb0\u5f55\u4ee3\u7406\u94fe\u4e2d\u7684\u6240\u6709 IP<\/span><br \/>\n            proxy_set_header X-Forwarded-For <span class=\"token variable\">$proxy_add_x_forwarded_for<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>            <span class=\"token comment\"># \u4ee3\u7406\u8bf7\u6c42\u8f6c\u53d1\u5230 upstream \u5b9a\u4e49\u7684 backend \u670d\u52a1\u5668<\/span><br \/>\n            proxy_pass http:\/\/backend<span class=\"token punctuation\">;<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><\/p>\n<p>    upstream backend <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token comment\"># \u914d\u7f6e\u4e0a\u6e38\u670d\u52a1\u5668&#xff08;\u8d1f\u8f7d\u5747\u8861\u540e\u7aef&#xff09;<\/span><br \/>\n        <span class=\"token comment\"># \u8fd9\u91cc\u7684 IP \u4e3a nginx \u4e0b\u53d1\u6d41\u91cf\u7684\u540e\u7aef\u670d\u52a1\u5668 IP&#xff08;\u53ef\u4ee5\u6dfb\u52a0\u591a\u4e2a&#xff09;<\/span><br \/>\n        server <span class=\"token number\">192.0<\/span>.0.1:80 <span class=\"token assign-left variable\">weight<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">10<\/span> <span class=\"token assign-left variable\">max_fails<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>        <span class=\"token comment\"># keepalive \u8fde\u63a5\u6c60\u5927\u5c0f&#xff0c;\u51cf\u5c11 TCP \u8fde\u63a5\u5efa\u7acb\u7684\u5f00\u9500<\/span><br \/>\n        keepalive <span class=\"token number\">100000<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<li>\u542f\u52a8 nginx<\/li>\n<p><span class=\"token function\">mkdir<\/span> <span class=\"token parameter variable\">-p<\/span> \/www\/wwwlogs<br \/>\n\/usr\/local\/nginx\/sbin\/nginx<\/p>\n<p>\/usr\/local\/nginx\/sbin\/nginx <span class=\"token parameter variable\">-s<\/span> stop<\/p>\n<p>\/usr\/local\/nginx\/sbin\/nginx <span class=\"token parameter variable\">-s<\/span> reload<\/p>\n<p><span class=\"token function\">ps<\/span> <span class=\"token parameter variable\">-ef<\/span> <span class=\"token operator\">|<\/span> <span class=\"token function\">grep<\/span> nginx <span class=\"token comment\"># \u67e5\u770b\u670d\u52a1\u8fdb\u7a0b<\/span><\/p>\n<li>\u589e\u52a0\u5b9a\u65f6\u4efb\u52a1\u914d\u7f6e&#xff0c;\u5b9a\u671f\u6e05\u7406 nginx \u65e5\u5fd7<\/li>\n<p>\u5199\u4e2a\u5b9a\u65f6\u4efb\u52a1\u628a nginx \u7684\u65e5\u5fd7\u6e05\u4e00\u6e05  \/etc\/crontab<br \/>\n*  *    * * *   root    <span class=\"token builtin class-name\">echo<\/span> <span class=\"token number\">1<\/span> <span class=\"token operator\">&gt;<\/span> \/www\/wwwlogs\/dimc.byted.org.log<br \/>\n*  *    * * *   root    <span class=\"token builtin class-name\">echo<\/span> <span class=\"token number\">1<\/span> <span class=\"token operator\">&gt;<\/span> \/www\/wwwlogs\/dimc.byted.org.error.log<\/p>\n<h3>nginx \u914d\u7f6e\u4e2d\u6700\u5173\u952e\u7684\u53c2\u6570<\/h3>\n<li> listen <span class=\"token punctuation\">[<\/span>::<span class=\"token punctuation\">]<\/span>:80<span class=\"token punctuation\">;<\/span> <span class=\"token comment\"># \u8fd9\u91cc\u8868\u793a\u4f60\u8981\u76d1\u542c\u6240\u6709 IPv6 \u7684 80 \u7aef\u53e3\u6d41\u91cf\u3002<\/span>\n <\/li>\n<li>\n<p>\u8ba9 nginx \u4f7f\u7528\u957f\u8fde\u63a5&#xff0c;\u9632\u6b62\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\u56e0\u8fde\u63a5\u6570\u6d88\u8017\u5b8c\u5bfc\u81f4\u7684\u6027\u80fd\u74f6\u9888\u3002<\/p>\n<p>\u53c2\u8003\u6587\u6863&#xff1a;https:\/\/blog.51cto.com\/lookingdream\/2487955<\/p>\n<\/li>\n<p><span class=\"token comment\"># \u8bbe\u5b9a\u8fde\u63a5\u7684 Keep-Alive \u8d85\u65f6\u65f6\u95f4&#xff08;0 \u4ee3\u8868\u5173\u95ed keep-alive&#xff09;<\/span><br \/>\n<span class=\"token comment\"># keepalive_timeout  0;<\/span><br \/>\nkeepalive_timeout  120s<span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\"># \u8bbe\u5b9a\u4e00\u4e2a\u8fde\u63a5\u5185\u6700\u5927\u8bf7\u6c42\u6570&#xff0c;\u907f\u514d\u957f\u8fde\u63a5\u5360\u7528\u8fc7\u591a\u8d44\u6e90<\/span><br \/>\nkeepalive_requests <span class=\"token number\">100000<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>proxy_http_version <span class=\"token number\">1.1<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\"># \u5728 http 1.1 \u7248\u672c\u4e4b\u540e\u624d\u652f\u6301\u957f\u8fde\u63a5&#xff0c;\u6240\u4ee5\u8fd9\u4e00\u70b9\u975e\u5e38\u91cd\u8981<\/span><br \/>\nproxy_set_header Connection <span class=\"token string\">&#034;&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\"># \u8bbe\u7f6e Connection \u4e3a\u957f\u8fde\u63a5&#xff0c;\u9ed8\u8ba4\u4e3a no<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb806\u6b21\uff0c\u70b9\u8d5e8\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u5728\u5b9e\u9645\u751f\u4ea7\u8fc7\u7a0b\u4e2d\uff0c\u7531\u4e8e\u5404\u79cd\u539f\u56e0\uff0c\u6211\u4eec\u7684\u5728\u7ebf\u670d\u52a1\u642d\u5efa\u5728\u706b\u5c71\u4e91\u670d\u52a1\u5668\u4e0a\uff0c\u4f7f\u7528\u706b\u5c71\u4e91\u5305\u62ec ECS\u3001CLB\u3001PLB \u7b49\u7ec4\u4ef6\u8fdb\u884c\u7f51\u7edc\u901a\u4fe1\uff0c\u5e76\u4e14\u901a\u8fc7\u4e13\u7ebf\u63a5\u53d7\u6765\u81ea\u67d0\u516c\u53f8\u5185\u90e8\u6d41\u91cf\u3002\u4f46\u662f\u5728\u5927\u6982 22~23 \u5e74\uff0c\u67d0\u516c\u53f8\u8981\u628a\u6240\u6709\u7f51\u7edc\u6d41\u91cf\u53d8\u4e3a IPv6 \u5f80\u4e0b\u53d1\uff0c\u706b\u5c71\u4e91\u7684 CLB \u548c PLB \u8fd8\u4e0d\u652f\u6301 IPv6\uff0c\u90a3\u6211\u4eec\u5c31\u9762\u4e34\u7740\u65ad\u6d41\u7684\u98ce\u9669\u3002\u7ecf\u8c03\u7814\u548c\u5b66\u4e60\uff0c\u4e86\u89e3\u5230\u53ef\u4ee5\u901a\u8fc7 nginx \u6765\u642d\u5efa\u4e00\u4e2a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u91cc\uff0c\u628a IPv6 \u7684\u6d41\u91cf\u8f6c\u6210 IPv4 \u5f80\u4e0b\u53d1\uff0c\u8fd9\u6837\u5c31\u89e3\u51b3\u4e86\u6211\u4eec\u7684\u95ee\u9898\u3002\u672c\u7bc7\u6587\u7ae0\u4e5f\u662f\u8bb0\u5f55\u4e00\u4e0b\u5f53\u65f6\u7684\u642d\u5efa\u8fc7\u7a0b\u548c\u6b65\u9aa4\uff0c\u4ee5\u53ca\u8e29\u8fc7\u7684\u5751\u3002_ipv6\u8f6cipv4\u670d\u52a1\u5668\u642d\u5efa<\/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],"topic":[],"class_list":["post-9079","post","type-post","status-publish","format-standard","hentry","category-server","tag-nginx"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>nginx \u642d\u5efa IPv6 -\uff1e IPv4 \u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668 - \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\/9079.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"nginx \u642d\u5efa IPv6 -\uff1e IPv4 \u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb806\u6b21\uff0c\u70b9\u8d5e8\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u5728\u5b9e\u9645\u751f\u4ea7\u8fc7\u7a0b\u4e2d\uff0c\u7531\u4e8e\u5404\u79cd\u539f\u56e0\uff0c\u6211\u4eec\u7684\u5728\u7ebf\u670d\u52a1\u642d\u5efa\u5728\u706b\u5c71\u4e91\u670d\u52a1\u5668\u4e0a\uff0c\u4f7f\u7528\u706b\u5c71\u4e91\u5305\u62ec ECS\u3001CLB\u3001PLB \u7b49\u7ec4\u4ef6\u8fdb\u884c\u7f51\u7edc\u901a\u4fe1\uff0c\u5e76\u4e14\u901a\u8fc7\u4e13\u7ebf\u63a5\u53d7\u6765\u81ea\u67d0\u516c\u53f8\u5185\u90e8\u6d41\u91cf\u3002\u4f46\u662f\u5728\u5927\u6982 22~23 \u5e74\uff0c\u67d0\u516c\u53f8\u8981\u628a\u6240\u6709\u7f51\u7edc\u6d41\u91cf\u53d8\u4e3a IPv6 \u5f80\u4e0b\u53d1\uff0c\u706b\u5c71\u4e91\u7684 CLB \u548c PLB \u8fd8\u4e0d\u652f\u6301 IPv6\uff0c\u90a3\u6211\u4eec\u5c31\u9762\u4e34\u7740\u65ad\u6d41\u7684\u98ce\u9669\u3002\u7ecf\u8c03\u7814\u548c\u5b66\u4e60\uff0c\u4e86\u89e3\u5230\u53ef\u4ee5\u901a\u8fc7 nginx \u6765\u642d\u5efa\u4e00\u4e2a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u91cc\uff0c\u628a IPv6 \u7684\u6d41\u91cf\u8f6c\u6210 IPv4 \u5f80\u4e0b\u53d1\uff0c\u8fd9\u6837\u5c31\u89e3\u51b3\u4e86\u6211\u4eec\u7684\u95ee\u9898\u3002\u672c\u7bc7\u6587\u7ae0\u4e5f\u662f\u8bb0\u5f55\u4e00\u4e0b\u5f53\u65f6\u7684\u642d\u5efa\u8fc7\u7a0b\u548c\u6b65\u9aa4\uff0c\u4ee5\u53ca\u8e29\u8fc7\u7684\u5751\u3002_ipv6\u8f6cipv4\u670d\u52a1\u5668\u642d\u5efa\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/9079.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T09:08:26+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\/9079.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/9079.html\",\"name\":\"nginx \u642d\u5efa IPv6 -\uff1e IPv4 \u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T09:08:26+00:00\",\"dateModified\":\"2025-04-18T09:08:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/9079.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/9079.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/9079.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"nginx \u642d\u5efa IPv6 -\uff1e IPv4 \u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668\"}]},{\"@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":"nginx \u642d\u5efa IPv6 -\uff1e IPv4 \u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668 - \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\/9079.html","og_locale":"zh_CN","og_type":"article","og_title":"nginx \u642d\u5efa IPv6 -\uff1e IPv4 \u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb806\u6b21\uff0c\u70b9\u8d5e8\u6b21\uff0c\u6536\u85cf2\u6b21\u3002\u5728\u5b9e\u9645\u751f\u4ea7\u8fc7\u7a0b\u4e2d\uff0c\u7531\u4e8e\u5404\u79cd\u539f\u56e0\uff0c\u6211\u4eec\u7684\u5728\u7ebf\u670d\u52a1\u642d\u5efa\u5728\u706b\u5c71\u4e91\u670d\u52a1\u5668\u4e0a\uff0c\u4f7f\u7528\u706b\u5c71\u4e91\u5305\u62ec ECS\u3001CLB\u3001PLB \u7b49\u7ec4\u4ef6\u8fdb\u884c\u7f51\u7edc\u901a\u4fe1\uff0c\u5e76\u4e14\u901a\u8fc7\u4e13\u7ebf\u63a5\u53d7\u6765\u81ea\u67d0\u516c\u53f8\u5185\u90e8\u6d41\u91cf\u3002\u4f46\u662f\u5728\u5927\u6982 22~23 \u5e74\uff0c\u67d0\u516c\u53f8\u8981\u628a\u6240\u6709\u7f51\u7edc\u6d41\u91cf\u53d8\u4e3a IPv6 \u5f80\u4e0b\u53d1\uff0c\u706b\u5c71\u4e91\u7684 CLB \u548c PLB \u8fd8\u4e0d\u652f\u6301 IPv6\uff0c\u90a3\u6211\u4eec\u5c31\u9762\u4e34\u7740\u65ad\u6d41\u7684\u98ce\u9669\u3002\u7ecf\u8c03\u7814\u548c\u5b66\u4e60\uff0c\u4e86\u89e3\u5230\u53ef\u4ee5\u901a\u8fc7 nginx \u6765\u642d\u5efa\u4e00\u4e2a\u53cd\u5411\u4ee3\u7406\u670d\u52a1\u91cc\uff0c\u628a IPv6 \u7684\u6d41\u91cf\u8f6c\u6210 IPv4 \u5f80\u4e0b\u53d1\uff0c\u8fd9\u6837\u5c31\u89e3\u51b3\u4e86\u6211\u4eec\u7684\u95ee\u9898\u3002\u672c\u7bc7\u6587\u7ae0\u4e5f\u662f\u8bb0\u5f55\u4e00\u4e0b\u5f53\u65f6\u7684\u642d\u5efa\u8fc7\u7a0b\u548c\u6b65\u9aa4\uff0c\u4ee5\u53ca\u8e29\u8fc7\u7684\u5751\u3002_ipv6\u8f6cipv4\u670d\u52a1\u5668\u642d\u5efa","og_url":"https:\/\/www.wsisp.com\/helps\/9079.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T09:08:26+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\/9079.html","url":"https:\/\/www.wsisp.com\/helps\/9079.html","name":"nginx \u642d\u5efa IPv6 -\uff1e IPv4 \u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T09:08:26+00:00","dateModified":"2025-04-18T09:08:26+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/9079.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/9079.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/9079.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"nginx \u642d\u5efa IPv6 -\uff1e IPv4 \u53cd\u5411\u4ee3\u7406\u670d\u52a1\u5668"}]},{"@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\/9079","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=9079"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/9079\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=9079"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=9079"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=9079"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=9079"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}