{"id":385619,"date":"2021-03-11T10:53:01","date_gmt":"2021-03-11T02:53:01","guid":{"rendered":"http:\/\/4563.org\/?p=385619"},"modified":"2021-03-11T10:53:01","modified_gmt":"2021-03-11T02:53:01","slug":"%e5%b0%8f%e7%99%bd%e8%af%b7%e6%95%99%e4%b8%80%e4%b8%aa-nginx-%e9%87%8d%e5%ae%9a%e5%90%91%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=385619","title":{"rendered":"[!]\u5c0f\u767d\u8bf7\u6559\u4e00\u4e2a nginx \u91cd\u5b9a\u5411\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  [!]\u5c0f\u767d\u8bf7\u6559\u4e00\u4e2a nginx \u91cd\u5b9a\u5411\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zhuzhibin <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<pre><code>server     {         listen 80;         #listen [::]:80;         server_name a.com b.com ;     } <\/code><\/pre>\n<p>\u73b0\u5728\u8bbf\u95ee a.com \u4f1a\u8d70 LB,443 \u8f6c\u53d1\u5230 80 \u7aef\u53e3\u3002<\/p>\n<p>\u73b0\u5728\u662f\u671f\u671b\u662f\u671f\u671b\u8bbf\u95ee a.com \u7684\u6240\u6709\u94fe\u63a5\u90fd\u4f1a 301 \u91cd\u5b9a\u5411\u5230 b.com \uff0c\u4f8b\u5982 a.com\/xx-&gt;b.com\/xx<\/p>\n<p>\u6211\u5c1d\u8bd5\u4e86\u4ee5\u4e0b\u914d\u7f6e\uff0c\u4f46\u662f\u53d1\u73b0\u6709\u4e9b\u95ee\u9898,\u4e0d\u751f\u6548\uff0c\u6709\u4e9b\u8def\u5f84\u4f1a\u6c38\u4e45\u91cd\u5b9a\u5411 a.com\/a.com\/a.com\/xxx<\/p>\n<pre><code>  if ($host ~ \"a.com\") {        return 301 https:\/\/b.com$request_uri;     }      <\/code><\/pre>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>4<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5360642\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhuzhibin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6ef4\u6ef4\u6ef4                                                             <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5360643\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ysc3839 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u540c\u57df\u540d\u5206\u6210\u4e24\u4e2a server block\uff0c\u4e0d\u8981\u7528 if \u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5360644\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhuzhibin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ysc3839 \u6211\u521a\u521a\u8bd5\u4e86\u4e24\u4e2a server<\/p>\n<p>&#8220;`<br \/>server<br \/> {<br \/> listen 80;<br \/> #listen [::]:80;<br \/> server_name b.com ;<br \/> }<\/p>\n<p>server<br \/> {<br \/> listen 80;<br \/> #listen [::]:80;<br \/> server_name a.com ;<br \/> return 301 https:\/\/b$request_uri;<br \/> }<\/p>\n<p>&#8220;`<\/p>\n<p>\u4e0a\u9762\u8fd9\u6837\u4f1a\u63d0\u793a\u8de8\u57df\u95ee\u9898<br \/>Origin a.com is not allowed by Access-Control-Allow-Origin.<\/p>\n<p>\u7136\u540e\u6211\u5728\u4e0b\u9762 server \u52a0\u4e86 <\/p>\n<p>&#8220;`<br \/> add_header Access-Control-Allow-Origin *;<\/p>\n<p>&#8220;`<\/p>\n<p>\u8fd8\u662f GG \u54e6                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5360645\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zhuzhibin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5df2\u89e3\u51b3 ~ LB \u6709\u591a\u53f0\u673a\u5668\uff0c\u6ca1\u6709\u8e22\u5b8c\u673a\u5668\uff0c\u53ea\u6539\u4e86\u4e00\u53f0\u673a\u5668\u7684\u914d\u7f6e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>[!]\u5c0f\u767d\u8bf7\u6559\u4e00\u4e2a nginx \u91cd&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/385619"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=385619"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/385619\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=385619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=385619"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=385619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}