Configuring Static Website Hosting for a Bucket
Function
You can host static website resources such as HTML web pages, flash files, or audio and video files in an OBS bucket, so that you can provide these hosted resources using the bucket's website endpoint to end users. Typical use cases include:
- Redirecting all requests to another website
- Redirecting specific requests to another website
This API configures static website hosting for a bucket.
Constraints
- Periods (.) should be avoided in the target bucket name, or there may be certificate verification failures on the client when you use HTTPS for access.
- The request body of the website configuration cannot exceed 10 KB.
- To configure static website hosting for a bucket, you must be the bucket owner or have the required permission (obs:bucket:PutBucketWebsite granted using IAM or PutBucketWebsite granted using a bucket policy). For details, see Differences Between OBS Permissions Control Methods, Using IAM Roles or Policies to Grant Access to OBS, and Creating a Custom Bucket Policy.
Command Line Structure
- Windows
obsutil website obs://bucket -method=put -localfile=xxx [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
- macOS or Linux
./obsutil website obs://bucket -method=put -localfile=xxx [-config=xxx] [-e=xxx] [-i=xxx] [-k=xxx] [-t=xxx]
Examples
- In Windows, run obsutil website obs://test-bucket -method=put -localfile=d:\temp\website.xml to configure static website hosting for bucket bucket using the website.xml file.
obsutil website obs://test-bucket -method=put -localfile=d:\temp\website.xml Start at 2024-09-30 07:59:28.8675681 +0000 UTC Put website configuration succeed for bucket [test-bucket], requestId is [000001996F7400854017D9959895ABE0]
Parameter Description
| Parameter | Optional or Mandatory | Description |
|---|---|---|
| bucket | Mandatory | The bucket name |
| method | Mandatory | The method. Set this parameter to put when configuring static website hosting for a bucket. |
| localfile | Mandatory | The path of the local website configuration file to be imported |
| config | Optional (additional parameter) | The user-defined configuration file for executing the current command. For details about parameters that can be configured, see Configuration Parameters. |
| e | Optional (additional parameter) | The endpoint |
| i | Optional (additional parameter) | The user's AK |
| k | Optional (additional parameter) | The user's SK |
| t | Optional (additional parameter) | The user's security token |
Helpful Links
- For details about the API for configuring static website hosting for a bucket, see Configuring Static Website Hosting for a Bucket.
- For details about the meanings, causes, and handling methods of error codes that may be returned during the operation, see OBS Error Codes.
- For the FAQ about static website hosting, see Static Website Hosting FAQ.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot