{Alibaba OSS} 静的ウェブサイトのホスティング

 

https://qiita.com/morozumi_h/items/a50a82a2b0825b101756
https://techblog.ap-com.co.jp/entry/2020/06/16/123020


-- 1. バケット作成


aliyun oss mb oss://backet123 \
--storage-class Standard \
--redundancy-type LRS \
--acl public-read 


aliyun oss ls 
aliyun oss ls -s
aliyun oss stat oss://backet123


-- 2. 静的ウェブサイトの設定

cat <<-'EOF' > configuration.xml
<?xml version="1.0" encoding="UTF-8"?>
<WebsiteConfiguration>
  <IndexDocument>
    <Suffix>index.html</Suffix>
    <SupportSubDir>false</SupportSubDir>
    <Type>0</Type>
  </IndexDocument>
  <ErrorDocument>
    <Key>error.html</Key>
    <HttpStatus>404</HttpStatus>
  </ErrorDocument>
</WebsiteConfiguration>

EOF

 

aliyun oss website --method put oss://backet123 configuration.xml

aliyun oss website --method get oss://backet123

 

-- 3. htmlファイルアップロード


cat <<-'EOF' > index.html
<html>
  <head>
      <title>Hello OSS</title>
      <meta charset="utf-8">
  </head>
  <body>
      <p>This is the homepage.</p>
  </body>
</html>
EOF


cat <<-'EOF' > error.html
<html>
  <head>
      <title>Hello OSS</title>
      <meta charset="utf-8">
  </head>
  <body>
      <p>This is the error page</p>
  </body>
</html>
EOF

 

aliyun oss cp index.html oss://backet123

aliyun oss cp error.html oss://backet123


aliyun oss ls oss://backet123

aliyun oss ls oss://backet123 -s

 


-- 4. 動作確認


curl https://backet123.oss-ap-northeast-1.aliyuncs.com/

curl https://backet123.oss-ap-northeast-1.aliyuncs.com/aaa

 

-- 5. クリーンアップ

※最初にバケットを空にする必要がある

aliyun oss rm oss://backet123 --recursive --force 

aliyun oss ls oss://backet123 -s

aliyun oss rm oss://backet123 --bucket --force
aliyun oss ls -s