forked from docs/doc-exports
Reviewed-by: Sabelnikov, Dmitriy <dmitriy.sabelnikov@t-systems.com> Co-authored-by: zhangyue <zhangyue164@huawei.com> Co-committed-by: zhangyue <zhangyue164@huawei.com>
67 lines
8.9 KiB
HTML
67 lines
8.9 KiB
HTML
<a name="en-us_topic_0045853860"></a><a name="en-us_topic_0045853860"></a>
|
|
|
|
<h1 class="topictitle1">Configuring CORS</h1>
|
|
<div id="body8662426"><p id="en-us_topic_0045853860__a31bcd128aa4b449d980504a401069944">This section describes how to use CORS in HTML5 to implement cross-origin access.</p>
|
|
<div class="section" id="en-us_topic_0045853860__s933c5484fd734428b5e2e24bf708a8e5"><h4 class="sectiontitle">Procedure</h4><ol id="en-us_topic_0045853860__o862d87949b3749b8999099e7b0e994b8"><li id="en-us_topic_0045853860__l14c09c87ed8e4d6d825df226fcb4e8a0"><span>Log in to OBS Browser.</span></li><li id="en-us_topic_0045853860__l28ced4c89d6348f388c6282a4b38028f"><span>Select the bucket to be configured and click <strong id="en-us_topic_0045853860__b1150693314344">More</strong> > <strong id="en-us_topic_0045853860__b1715819392344">Configure CORS Rule</strong>.</span></li><li id="en-us_topic_0045853860__ldcffbc589f1641eb9cf4cd4a382d948a"><span>Click <strong id="en-us_topic_0045853860__b607881205161513">Add</strong>.</span><p><div class="note" id="en-us_topic_0045853860__n2de05562b8b243afaa8bdf04aa70141b"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="en-us_topic_0045853860__a912094b8b3c34376a437bde131f54db7">A bucket can have a maximum of 100 CORS rules configured.</p>
|
|
</div></div>
|
|
</p></li><li id="en-us_topic_0045853860__ld376f10636be4cfbbe4e7a7beabb99b9"><span>In the <strong id="en-us_topic_0045853860__b31769315353">Add CORS Rule</strong> dialog box that is displayed, enter CORS rules.</span><p><div class="fignone" id="en-us_topic_0045853860__fe30e6fe056434c66a690c9063d04e6bb"><span class="figcap"><b>Figure 1 </b>Adding a CORS rule</span><br><span><img id="en-us_topic_0045853860__image9932163915310" src="en-us_image_0129834236.png" title="Click to enlarge" class="imgResize"></span></div>
|
|
<p id="en-us_topic_0045853860__a75de0ac8ec7f4961b07a5097182bd1f9"><a href="#en-us_topic_0045853860__t810c07199d9d4fb4949e45cc402582a0">Table 1</a> describes parameters in CORS rules.</p>
|
|
|
|
<div class="tablenoborder"><a name="en-us_topic_0045853860__t810c07199d9d4fb4949e45cc402582a0"></a><a name="t810c07199d9d4fb4949e45cc402582a0"></a><table cellpadding="4" cellspacing="0" summary="" id="en-us_topic_0045853860__t810c07199d9d4fb4949e45cc402582a0" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameters in a CORS rule</caption><thead align="left"><tr id="en-us_topic_0045853860__r282c3ed8eee94e42b62d5849670244ca"><th align="left" class="cellrowborder" valign="top" width="32%" id="mcps1.3.2.2.4.2.3.2.3.1.1"><p id="en-us_topic_0045853860__a602c237b70394ce5a689bb6ebdca0c16">Parameter</p>
|
|
</th>
|
|
<th align="left" class="cellrowborder" valign="top" width="68%" id="mcps1.3.2.2.4.2.3.2.3.1.2"><p id="en-us_topic_0045853860__a1d5215e5897b4b16828bfbc8b1878a5a">Description</p>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody><tr id="en-us_topic_0045853860__r2ff60e1cc4c04df0bd1b01f6f2bb5196"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.2.2.4.2.3.2.3.1.1 "><p id="en-us_topic_0045853860__a157438a1cf0e4973a1bbe1e79572c531">Allowed Origin</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="68%" headers="mcps1.3.2.2.4.2.3.2.3.1.2 "><p id="en-us_topic_0045853860__af293f21d2e374fa4934e7bd8be3752eb">Specifies the origin of cross-origin requests. That is, requests from the origin can access the bucket. This parameter is mandatory.</p>
|
|
<p id="en-us_topic_0045853860__ac0e68ea7740c478ba86dfb9ee32ff300">Multiple matching rules are allowed. One rule occupies one line, and allows one wildcard character (<strong id="en-us_topic_0045853860__b15430134443519">*</strong>) at most. Example:</p>
|
|
<pre class="screen" id="en-us_topic_0045853860__scbcd7fb5598746eb8312b7ae6cacc05f">http://rds.example.com
|
|
https://*.vbs.example.com</pre>
|
|
</td>
|
|
</tr>
|
|
<tr id="en-us_topic_0045853860__rab81f76db9364bf8ab978a987ee0e07b"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.2.2.4.2.3.2.3.1.1 "><p id="en-us_topic_0045853860__a25b2e075e2234e10937f43f599273668">Allowed Method</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="68%" headers="mcps1.3.2.2.4.2.3.2.3.1.2 "><p id="en-us_topic_0045853860__a901f59948c80429583c364e96bd352c6">Specifies the method of cross-origin requests, that is, the operation type of buckets and objects. This parameter is mandatory. The following methods are included: Get, Post, Put, Delete, and Head.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="en-us_topic_0045853860__r467a5c6a833f4015bb22f4087de6b74c"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.2.2.4.2.3.2.3.1.1 "><p id="en-us_topic_0045853860__a6dc9a4d89e134b2aa83df07975ff13fe">Allowed Header</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="68%" headers="mcps1.3.2.2.4.2.3.2.3.1.2 "><p id="en-us_topic_0045853860__adea4598de03143f2a8e47195d17341d1">Specifies the allowed header of cross-origin requests. This parameter is optional. Only CORS requests matching the allowed header are valid.</p>
|
|
<p id="en-us_topic_0045853860__a055e9cbebabc4c85ad34a31b69b5ada3">You can enter multiple allowed headers (one per line) and each line can contain one wildcard character (*) at most. Spaces and special characters including <strong id="en-us_topic_0045853860__b56257227210">&:<</strong> are not allowed.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="en-us_topic_0045853860__r64d7889221344540a64115505d5e1e72"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.2.2.4.2.3.2.3.1.1 "><p id="en-us_topic_0045853860__a910e77b75bbd4c2986a23ce2aab35e6f">Exposed Header</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="68%" headers="mcps1.3.2.2.4.2.3.2.3.1.2 "><p id="en-us_topic_0045853860__a4e770b7fc6404388bcf68eb959df4401">Specifies the supplemented header in CORS responses, providing additional information for clients. This parameter is optional.</p>
|
|
<p id="en-us_topic_0045853860__a37cf726ebb9649ef98d0256ee1c35dc9">You can enter multiple exposed headers (one per line). Spaces and special characters including <strong id="en-us_topic_0045853860__b31335915574">*&:<</strong> are not allowed.</p>
|
|
</td>
|
|
</tr>
|
|
<tr id="en-us_topic_0045853860__r878b4e4c1aa9415ebabb6923463b8153"><td class="cellrowborder" valign="top" width="32%" headers="mcps1.3.2.2.4.2.3.2.3.1.1 "><p id="en-us_topic_0045853860__a69c5c5a0268b4a33a275a5109847d94c">Cache Duration (s)</p>
|
|
</td>
|
|
<td class="cellrowborder" valign="top" width="68%" headers="mcps1.3.2.2.4.2.3.2.3.1.2 "><p id="en-us_topic_0045853860__ab09e25a0b9b74b6a978e809ab22ba139">Mandatory. Specifies the duration that your browser can cache CORS responses, expressed in seconds. The default value is 100.</p>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</p></li><li id="en-us_topic_0045853860__l909d86eda87a4867840e3f70759c3d27"><span>Click <strong id="en-us_topic_0045853860__b49531058153717">OK</strong>.</span></li><li id="en-us_topic_0045853860__lb7780ddd3dc54401a277774fe33669f5"><span>Click <strong id="en-us_topic_0045853860__en-us_topic_0068417484_en-us_topic_0045853860_b28560655">OK</strong> to save the rules.</span><p><p id="en-us_topic_0045853860__p370795133812">After CORS is successfully configured, only the addresses specified for <strong id="en-us_topic_0045853860__b107079515389">Allowed Origin</strong> can access the bucket using the methods specified for <strong id="en-us_topic_0045853860__b270715515381">Allowed Method</strong>. For example, you configure a CORS rule for bucket <strong id="en-us_topic_0045853860__b18707855382">testbucket</strong> as follows:</p>
|
|
<ul id="en-us_topic_0045853860__ul1443611584382"><li id="en-us_topic_0045853860__li186402015388"><strong id="en-us_topic_0045853860__b15651520163813">Allowed Origin: www.example.com</strong></li><li id="en-us_topic_0045853860__li3857172315382"><strong id="en-us_topic_0045853860__b188588235387">Allowed Method: GET</strong></li><li id="en-us_topic_0045853860__li05043268389"><strong id="en-us_topic_0045853860__b650482611389">Allowed Header</strong>: left blank</li><li id="en-us_topic_0045853860__li10356182912387"><strong id="en-us_topic_0045853860__b935662993819">Exposed Header</strong>: left blank</li><li id="en-us_topic_0045853860__li3528559133811"><strong id="en-us_topic_0045853860__b14783232173816">Cache Duration (s): 100</strong></li></ul>
|
|
<p id="en-us_topic_0045853860__p46924516389">Then, OBS only allows GET requests from <strong id="en-us_topic_0045853860__b126851381379">www.example.com</strong> to access bucket <strong id="en-us_topic_0045853860__b1768617873718">testbucket</strong> and does not limit request headers. The client can cache CORS responses for 100 seconds.</p>
|
|
</p></li><li id="en-us_topic_0045853860__li944717573486"><span>In the displayed dialog box, click <strong id="en-us_topic_0045853860__obs_03_0022_b19371431195919">Close</strong> to close the dialog box.</span></li></ol>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="obs_03_0427.html">CORS</a></div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<script language="JavaScript">
|
|
<!--
|
|
image_size('.imgResize');
|
|
var msg_imageMax = "view original image";
|
|
var msg_imageClose = "close";
|
|
//--></script> |