{"id":396765,"date":"2021-03-14T03:23:16","date_gmt":"2021-03-13T19:23:16","guid":{"rendered":"http:\/\/4563.org\/?p=396765"},"modified":"2021-03-14T03:23:16","modified_gmt":"2021-03-13T19:23:16","slug":"%e6%b1%82%e5%8a%a9%ef%bc%8c%e5%85%b3%e4%ba%8e-nginx-%e9%9c%80%e8%a6%81%e8%ae%bf%e9%97%ae%e9%9d%99%e6%80%81%e8%b5%84%e6%ba%90%e9%89%b4%e6%9d%83%e7%9a%84%e4%b8%80%e4%b8%aa%e9%85%8d%e7%bd%ae%e9%97%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=396765","title":{"rendered":"\u6c42\u52a9\uff0c\u5173\u4e8e Nginx \u9700\u8981\u8bbf\u95ee\u9759\u6001\u8d44\u6e90\u9274\u6743\u7684\u4e00\u4e2a\u914d\u7f6e\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u6c42\u52a9\uff0c\u5173\u4e8e Nginx \u9700\u8981\u8bbf\u95ee\u9759\u6001\u8d44\u6e90\u9274\u6743\u7684\u4e00\u4e2a\u914d\u7f6e\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Keppel <\/span>  <span><i><\/i> 2<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>server { listen 14011; server_name localhost;<\/p>\n<pre><code>     #charset koi8-r;       #access_log  logs\/host.access.log  main;      location \/ {         root   \/;         index  index.html index.htm;     }       location \/upload {            if ($request_method = 'OPTIONS') {         add_header Access-Control-Allow-Origin *;         add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';         add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';         return 204;      }          auth_request \/auth;          root   \/;     }       location \/auth {     internal;     proxy_set_header Host $host;     proxy_pass_request_body off;     proxy_set_header Content-Length \"\";     proxy_pass http:\/\/127.0.0.1:14010\/auth;     }   }       <\/code><\/pre>\n<p>====================================================================== \u4ee5\u4e0a\u662f\u6211\u7684\u914d\u7f6e\uff0c\u56e0\u4e3a\u9700\u8981\u8bbf\u95ee\u9759\u6001\u8d44\u6e90\u8981\u9274\u6743\uff0c\u6240\u4ee5\u9700\u8981\u643a\u5e26\u8bf7\u6c42\u5934\u53d1\u8bf7\u6c42\uff0c\u4f46\u662f\u53d1\u9001 OPTIONS \u8bf7\u6c42\u7684\u65f6\u5019\u8de8\u57df\u4e86\uff0c\u52a0\u4e0a\u4e86\u7f51\u4e0a\u8bf4\u7684\u914d\u7f6e\u8fd8\u662f\u4e0d\u884c\uff0c\u6c42\u52a9\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>6<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5529118\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Keppel <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             QAQ                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5529119\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ch2 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u628a if ($request_method = &#8216;OPTIONS&#8217;) \u53bb\u6389<br \/>add_header Access-Control-Allow-Methods &#8216;GET, POST, OPTIONS&#8217;;<br \/>\u8fd9\u6761\u5c31\u591f\u4e86\uff0c\u5916\u9762\u4e0d\u7528\u518d\u5957\u4e2a if                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5529120\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Keppel <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ch2 \u8bd5\u8fc7\uff0c\u4e0d\u8d77\u4f5c\u7528\uff0c\u8bd5\u8fc7\u5404\u79cd\u65b9\u5f0f\uff0c\u90fd\u4e0d\u884c\uff0c\u6240\u4ee5\u6765\u6c42\u52a9\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5529121\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : NjcyNzMzNDQ3 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             add_header Access-Control-Allow-Origin *;<br \/>add_header Access-Control-Allow-Methods &#8216;GET, POST, OPTIONS&#8217;;<br \/>add_header Access-Control-Allow-Headers &#8216;DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization&#8217;;<\/p>\n<p># !!!!\u91cd\u8981 \u666e\u901a Ajax \u8bf7\u6c42\u76f4\u63a5\u53d1\u8d77\u8bf7\u6c42\u4e0d\u7528\u6dfb\u8fd9\u4e2a\u8bbe\u7f6e\u3002<br \/># Vuejs \u4f1a\u5148\u53d1\u8d77 option \u8bf7\u6c42\uff0c\u800c add_header \u652f\u6301\u7684 http \u72b6\u6001\u7801\u6709\u9650\uff0c\u5fc5\u987b\u6dfb\u52a0 http_code \u8fd4\u56de 204<br \/>if ($request_method = &#8216;OPTIONS&#8217;) {<br \/> return 204;<br \/>}                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5529122\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : NjcyNzMzNDQ3 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8bd5\u8bd5\u6211\u8fd9\u4e2a\uff0c\u6211\u4e4b\u524d\u5c31\u8fd9\u4e48\u914d\u7f6e\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5529123\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Keppel <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @NjcyNzMzNDQ3 \u6211\u80fd\u8bf4\u8fd9\u4e2a\u6211\u4e5f\u8bd5\u8fc7\u5417 =\u3002=                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u6c42\u52a9\uff0c\u5173\u4e8e Nginx \u9700\u8981\u8bbf\u95ee\u9759&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\/396765"}],"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=396765"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/396765\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=396765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=396765"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=396765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}