1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Cloudflare R2のオブジェクトを直接インターネットに公開してみる(r2.devのサブドメイン使用 本番環境非推奨)

Last updated at Posted at 2024-06-28

概要

R2のオブジェクト(htmlファイル)を直接インターネットに公開し、ブラウザからアクセスしてみる。

前提

下記のindex.htmlをアップロードして公開してみる。

index.html
<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
  <h1>Hello Cloudflare R2</h1>
</body>
</html>

注意

本設定を施すとインターネットにつながっている全世界の全端末からアップロードするオブジェクトが閲覧されることになる。
さらには一部機能が制限される。そのため本番運用では本方法は使わないことが推奨される。

方法

  1. 公開用バケット(筆者の場合バケット名は「public-r2-dev」)を追加

    • 位置情報: 自動
    • デフォルトのストレージ クラス: Standard
  2. バケットの詳細画面で「設定タブ」を開き下部の「r2.dev サブドメイン」の「アクセスを許可」をクリック

    CleanShot 2024-06-29 at 00.56.15@2x.png

    CleanShot 2024-06-29 at 01.06.42@2x.png

  3. ドラックアンドドロップでindex.htmlをバケットにアップロード

  4. アップロードしたオブジェクトの詳細を開き、URLをコピー

    CleanShot 2024-06-29 at 01.10.20@2x.png

  5. コピーしたURLをブラウザに貼り付けて、下記のようなページが表示されれば完了

    CleanShot 2024-06-29 at 01.11.28@2x.png

  6. 大した事ないファイルだが、世界中からアクセスできることは避けたいので本体験が終わったらバケットのr2.dev サブドメインの公開設定を「アクセスを許可しない」ボタンをクリックして公開しないように設定

参考文献

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?