From 2f9f6ced35ade7e654e6984754da6aff73170c11 Mon Sep 17 00:00:00 2001 From: "svenja.michal" Date: Fri, 17 Jan 2025 14:34:27 +0100 Subject: [PATCH] Spelling and formatting updates --- .../01.en.md | 136 ++++++++++-------- 1 file changed, 80 insertions(+), 56 deletions(-) diff --git a/tutorials/hetzner-object-storage-custom-domain/01.en.md b/tutorials/hetzner-object-storage-custom-domain/01.en.md index 6d5865c48..6e8226740 100644 --- a/tutorials/hetzner-object-storage-custom-domain/01.en.md +++ b/tutorials/hetzner-object-storage-custom-domain/01.en.md @@ -2,9 +2,9 @@ SPDX-License-Identifier: MIT path: "/tutorials/hetzner-object-storage-custom-domain" slug: "hetzner-object-storage-custom-domain" -date: "2025-01-05" -title: "Setup custom domain with S3-compatible object storage" -short_description: "This tutorial explains how to setup custom domain for S3-compatible object storage using reverse proxy." +date: "2025-01-17" +title: "Setup custom domain for S3-compatible object storage via reverse proxy" +short_description: "This tutorial explains how to setup custom domains for S3-compatible object storage using reverse proxy." tags: ["Custom domain", "Reverse proxy", "Object Storage"] author: "Ivan Zaitsev" author_link: "https://github.com/ivan-zaitsev" @@ -18,23 +18,23 @@ cta: "cloud" ## Introduction -This tutorial will guide you to setup custom domain for S3-compatible object storage using reverse proxy. -The advantages of custom domain is to enable seamless integration with existing infrastructure or services under a unified domain. +This tutorial will guide you to setup a custom domain for S3-compatible object storage using reverse proxy. +The advantages of a custom domain are to enable seamless integration with existing infrastructure or services under a unified domain. -A custom domain can be configured in various ways, such as using a CNAME record or a reverse proxy. +There are different ways to configure a custom domain, such as using a CNAME record or a reverse proxy. This tutorial focuses on configuring a custom domain using a reverse proxy. **Prerequisites** * A server (e.g. with [Hetzner Cloud](https://www.hetzner.com/cloud/)) -* A S3-compatible bucket (e.g. with [Hetzner](https://www.hetzner.com)) +* An S3-compatible bucket (e.g. with [Hetzner](https://www.hetzner.com/storage/object-storage/)) * A domain you want to use (e.g. `storage.example.com`). ## Step 1 - Create Object Storage Bucket -Create a S3-compatible bucket. +Create an S3-compatible bucket. With Hetzner, see the getting started "[Creating a Bucket](https://docs.hetzner.com/storage/object-storage/getting-started/creating-a-bucket)". -Make sure it is set to public access permissions. No much benefit of using custom domain for private buckets. +Make sure it is set to public access permissions. Not much benefit to using a custom domain for private buckets. Create S3 credentials to access your bucket. With Hetzner, see the getting started "[Generating S3 keys](https://docs.hetzner.com/storage/object-storage/getting-started/generating-s3-keys)". @@ -42,7 +42,7 @@ With Hetzner, see the getting started "[Generating S3 keys](https://docs.hetzner ## Step 2 - Create Server Create a new server. -With Hetzner, see the getting started "[Creating a Server](https://docs.hetzner.com/cloud/servers/getting-started/creating-a-server)"). +With Hetzner, see the getting started "[Creating a Server](https://docs.hetzner.com/cloud/servers/getting-started/creating-a-server)". To install Docker and Docker Compose, follow the [official Docker documentation](https://docs.docker.com/engine/install/). ## Step 3 - Deploy Caddy @@ -52,65 +52,84 @@ SSH to your server `ssh root@`. Create a directory for your Docker Compose files and folders for the persistent storage of the Caddy container: ```bash -mkdir -p /opt/caddy/data +sudo mkdir -p /opt/caddy/data ``` -### Step 3.1 - Create docker deployment and configuration files - -`vim /opt/caddy/compose.yaml` - -```yaml -services: - caddy: - container_name: caddy - image: caddy:latest - restart: unless-stopped - ports: - - 80:80 - - 443:443 - volumes: - - ./data/Caddyfile:/etc/caddy/Caddyfile - - ./data/certs:/certs - - ./data/config:/config - - ./data/data:/data - - ./data/sites:/srv -``` - -`vim /opt/caddy/data/Caddyfile` - -```text -storage.example.com { - tls { - issuer acme { - dir https://acme-v02.api.letsencrypt.org/directory - } - } -} - -storage.example.com:443 { - reverse_proxy https://fsn1.your-objectstorage.com { - header_up Host {http.reverse_proxy.upstream.hostport} - header_up X-Forwarded-Host {host} +### Step 3.1 - Create Docker deployment and configuration files + +* Add a Docker compose file + + ```bash + sudo vim /opt/caddy/compose.yaml + ``` + Add the following content: + ```yaml + services: + caddy: + container_name: caddy + image: caddy:latest + restart: unless-stopped + ports: + - 80:80 + - 443:443 + volumes: + - ./data/Caddyfile:/etc/caddy/Caddyfile + - ./data/certs:/certs + - ./data/config:/config + - ./data/data:/data + - ./data/sites:/srv + ``` + +
+ +* Add a Caddyfile + + ```bash + sudo vim /opt/caddy/data/Caddyfile + ``` + Add the following content: + + > Replace `storage.example.com` with your own domain. + > Replace `fsn1.your-objectstorage.com` with the endpoint of your object storage bucket. If the bucket name comes after the endpoint (e.g. `https://s3-endpoint.example.org/`) add your endpoint without the bucket name. + + ```text + storage.example.com { + + tls { + issuer acme { + dir https://acme-v02.api.letsencrypt.org/directory + } + } + + reverse_proxy https://.fsn1.your-objectstorage.com { + #reverse_proxy https://s3-endpoint.example.org { + header_up Host {http.reverse_proxy.upstream.hostport} + header_up X-Forwarded-Host {host} + } } -} -``` + ``` ### Step 3.2 - Start Caddy ```bash cd /opt/caddy - docker compose up -d +docker ps ``` -**Note:** +After the Docker container started, you can access your files via `storage.example.com`. -The request url would be `https://storage.example.com/bucket-name/object.txt`. -It is equivalent to `https://fsn1.your-objectstorage.com/bucket-name/object.txt`. +If your bucket name comes after the endpoint, note: -### Step 3.3 - Create kubernetes deployment and configuration files (Optional) +The request URL would be `https://storage.example.com//object.txt`. +It is equivalent to `https://s3-endpoint.example.org//object.txt`. -Assuming you already have configured kubernetes, gateway api. +### Step 3.3 - Create Kubernetes deployment and configuration files (Optional) + +Assuming you already have configured Kubernetes, [gateway API](https://gateway-api.sigs.k8s.io/guides/#installing-gateway-api). + +> Replace `storage.example.com` with your own domain. +> Replace `fsn1.your-objectstorage.com` with the endpoint of your object storage bucket. If the bucket name comes after the endpoint (e.g. `https://s3-endpoint.example.org/`) add your endpoint without the bucket name. ```yaml apiVersion: v1 @@ -171,7 +190,8 @@ metadata: data: Caddyfile: | storage.example.com:80 { - reverse_proxy https://fsn1.your-objectstorage.com { + reverse_proxy https://.fsn1.your-objectstorage.com { + #reverse_proxy https://s3-endpoint.example.org { header_up Host {http.reverse_proxy.upstream.hostport} header_up X-Forwarded-Host {host} } @@ -201,6 +221,10 @@ spec: weight: 100 ``` +## Conclusion + +You should now be able to access the contents of your S3-compatible object storage via a custom domain. + ##### License: MIT