The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
add s3 configuration how-to for self-hosted
Andrey A.e43e7fff4ec5
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex 69dd8d4d5d5..3e72297149e 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -2832,6 +2832,8 @@ export const self_hosting: NavMenuConstant = {items: [{ name: 'Enabling MCP server', url: '/guides/self-hosting/enable-mcp' },{ name: 'Restore from Platform', url: '/guides/self-hosting/restore-from-platform' },+ { name: 'Configure S3 Storage', url: '/guides/self-hosting/self-hosted-s3' },+ { name: 'Copy Storage from Platform', url: '/guides/self-hosting/copy-from-platform-s3' },],},{diff --git a/apps/docs/content/guides/self-hosting/copy-from-platform-s3.mdx b/apps/docs/content/guides/self-hosting/copy-from-platform-s3.mdxnew file mode 100644index 00000000000..2c98be8144f--- /dev/null+++ b/apps/docs/content/guides/self-hosting/copy-from-platform-s3.mdx@@ -0,0 +1,159 @@+---+title: 'Copy Storage Objects from Platform'+description: 'Copy storage objects from a managed Supabase project to a self-hosted instance using rclone.'+subtitle: 'Copy storage objects from a managed Supabase project to a self-hosted instance using rclone.'+---++{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+This guide walks you through copying storage objects from a managed Supabase platform project to a self-hosted instance using [rclone](https://rclone.org/) with S3-to-S3 copy.++<Admonition type="caution">++Direct file copy (e.g., downloading files and placing them into `volumes/storage/`) does not work. Self-hosted Storage uses an internal file structure that differs from what you get when downloading files from the platform. Use the S3 protocol to transfer objects so that Storage creates the correct metadata records.++</Admonition>++## Before you begin++You need:++- A working self-hosted Supabase instance with the S3 protocol endpoint enabled - see [Configure S3 Storage](/docs/guides/self-hosting/self-hosted-s3#enable-the-s3-protocol-endpoint)+- Your platform project's S3 credentials - generated from the [S3 Configuration](/dashboard/project/_/storage/s3) page+- Matching buckets created on your self-hosted instance+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+- [rclone](https://rclone.org/install/) installed on the machine running the copy++## Step 1: Get platform S3 credentials++In your managed Supabase project dashboard, go to **Storage** > **S3 Configuration** > **Access keys**. Generate a new access key pair and copy:++- **Endpoint**: `https://<project-ref>.supabase.co/storage/v1/s3`+- **Region**: your project's region (e.g., `us-east-1`)+- **Access Key ID** and **Secret access key**++<Admonition type="note">++For better performance with large files, use the direct storage hostname: `https://<project-ref>.storage.supabase.co/storage/v1/s3`++</Admonition>++## Step 2: Create buckets on self-hosted++Buckets must exist on the destination before you can copy objects into them. You can create them through dashboard UI, or with **SQL Editor**.++<Admonition type="tip">++If you already restored your platform database to self-hosted using the [restore guide](/docs/guides/self-hosting/restore-from-platform), your bucket definitions are already present. You can skip this step.++</Admonition>++To list your platform buckets, connect to your platform database and run:++```sql+SELECT id, name, public FROM storage.buckets ORDER BY name;+```++Then create matching buckets on your self-hosted instance. Connect to your self-hosted database and run:++```sql+INSERT INTO storage.buckets (id, name, public)+VALUES+ ('your-storage-bucket', 'your-storage-bucket', false)+ON CONFLICT (id) DO NOTHING;+```++Repeat for each bucket, setting `public` to `true` or `false` as appropriate.++{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+## Step 3: Configure rclone+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+Create or edit your rclone configuration file (`~/.config/rclone/rclone.conf`):++```ini rclone.conf+[platform]+type = s3+provider = Other+access_key_id = your-platform-access-key-id+secret_access_key = your-platform-secret-access-key+endpoint = https://your-project-ref.supabase.co/storage/v1/s3+region = your-project-region++[self-hosted]+type = s3+provider = Other+access_key_id = your-self-hosted-access-key-id+secret_access_key = your-self-hosted-secret-access-key+endpoint = http://your-domain:8000/storage/v1/s3+region = your-self-hosted-region+```++Replace the credentials with your actual values. For self-hosted, use the `REGION`, `S3_PROTOCOL_ACCESS_KEY_ID` and `S3_PROTOCOL_ACCESS_KEY_SECRET` you configured in [Configure S3 Storage](/docs/guides/self-hosting/self-hosted-s3#enable-the-s3-protocol-endpoint).++Verify both remotes connect:++```bash+rclone lsd platform:+rclone lsd self-hosted:+```++Both commands should list your buckets.++## Step 4: Copy objects++Copy a single bucket:++```bash+rclone copy platform:your-storage-bucket self-hosted:your-storage-bucket --progress+```++To copy all buckets:++```bash+for bucket in $(rclone lsf platform: | tr -d '/'); do+ echo "Copying bucket: $bucket"+ rclone copy "platform:$bucket" "self-hosted:$bucket" --progress+done+```++<Admonition type="note">++For large migrations, consider adding `--transfers 4` to increase parallelism, or `--checkers 8` to speed up the comparison phase. See the [flags documentation](https://rclone.org/flags/) for all options.++</Admonition>++## Verify++Compare object counts between source and destination:++```bash+rclone size platform:your-storage-bucket && \+rclone size self-hosted:your-storage-bucket+```++Open Studio on your self-hosted instance and browse the storage buckets to confirm files are accessible.++## Troubleshooting++### Signature errors++If you see `SignatureDoesNotMatch` when connecting to either remote:++- **Platform**: Regenerate S3 access keys from your project's Storage Settings. Ensure the endpoint URL includes `/storage/v1/s3`.+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+- **Self-hosted**: Verify that `REGION`, `S3_PROTOCOL_ACCESS_KEY_ID` and `S3_PROTOCOL_ACCESS_KEY_SECRET` in `.env` file match your rclone config.++### Bucket not found+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+If rclone reports that a bucket doesn't exist on the self-hosted side, create it first - see [Step 2](#step-2-create-buckets-on-self-hosted). The S3 protocol does not auto-create buckets on copy.++### Timeouts on large files+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+For very large files, increase rclone's timeout:++```bash+rclone copy platform:your-storage-bucket self-hosted:your-storage-bucket --timeout 30m+```++### Empty listing on platform++If `rclone lsd platform:` returns nothing, verify the endpoint URL ends with `/storage/v1/s3` and that the S3 access keys have not expired. Regenerate them from the dashboard if needed.diff --git a/apps/docs/content/guides/self-hosting/docker.mdx b/apps/docs/content/guides/self-hosting/docker.mdxindex d1f39a54d5c..f9c78a6eb46 100644--- a/apps/docs/content/guides/self-hosting/docker.mdx+++ b/apps/docs/content/guides/self-hosting/docker.mdx@@ -423,17 +423,10 @@ SMTP_SENDER_NAME=We recommend using [AWS SES](https://aws.amazon.com/ses/). It's extremely cheap and reliable. Restart all services to pick up the new configuration.#### Configuring S3 Storage+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+By default all files are stored locally on the server. You can connect Storage to an S3-compatible backend (AWS S3, MinIO, Cloudflare R2), enable the S3 protocol endpoint for tools like `rclone`, or both. These are independent features.-By default all files are stored locally on the server. You can configure the Storage service to use S3 by updating the following environment variables:--```yaml docker-compose.yml-storage:- environment: STORAGE_BACKEND=s3- GLOBAL_S3_BUCKET=name-of-your-s3-bucket- REGION=region-of-your-s3-bucket-```--You can find all the available options in the [storage repository](https://github.com/supabase/storage-api/blob/master/.env.sample). Restart the `storage` service to pick up the changes: `docker compose restart storage --no-deps`+See the [Configure S3 Storage](/docs/guides/self-hosting/self-hosted-s3) guide for detailed setup instructions.#### Configuring Supabase AI Assistantdiff --git a/apps/docs/content/guides/self-hosting/self-hosted-s3.mdx b/apps/docs/content/guides/self-hosting/self-hosted-s3.mdxnew file mode 100644index 00000000000..37ada206d74--- /dev/null+++ b/apps/docs/content/guides/self-hosting/self-hosted-s3.mdx@@ -0,0 +1,151 @@+---+title: 'Configure S3 Storage'+description: 'Enable S3-compatible client endpoint and set up an S3 backend for self-hosted Supabase Storage.'+subtitle: 'Enable S3-compatible client endpoint and set up an S3 backend for self-hosted Supabase Storage.'+---++Self-hosted Supabase Storage has two independent S3-related features:+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+- **S3 protocol endpoint** - an S3-compatible API that Storage exposes at `/storage/v1/s3`. This allows standard S3 tools like `rclone` and the AWS CLI to interact with your Storage instance.+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+- **S3 backend** - where Storage keeps data. By default, files are stored on the local filesystem. You can switch to an S3-compatible service (AWS S3, MinIO, etc.) for durability, scalability, or to use existing infrastructure.++You can configure either feature independently. For example, you can enable the S3 protocol endpoint to use `rclone` while keeping the default file-based storage, or switch to an S3 backend without enabling the S3 protocol endpoint.++## Enable the S3 protocol endpoint++The S3 protocol endpoint at `/storage/v1/s3` allows standard S3 clients to interact with your self-hosted Storage instance. It works with any storage backend, including the default file-based storage - you do not need to configure an S3 backend first. The Supabase REST API and SDK do not use the S3 protocol.++Make sure to check that `REGION`, `S3_PROTOCOL_ACCESS_KEY_ID` and `S3_PROTOCOL_ACCESS_KEY_SECRET` are properly configured in you `.env` file. Read more about the secrets and passwords in [Configuring and securing Supabase](/docs/guides/self-hosting/docker#configuring-and-securing-supabase).++```yaml+storage:+ environment:+ # ... existing variables ...+ REGION: ${REGION}+ S3_PROTOCOL_ACCESS_KEY_ID: ${S3_PROTOCOL_ACCESS_KEY_ID}+ S3_PROTOCOL_ACCESS_KEY_SECRET: ${S3_PROTOCOL_ACCESS_KEY_SECRET}+```++### Test with the AWS CLI++```bash+( set -a && \+source .env > /dev/null 2>&1 && \+echo "" && \+AWS_ACCESS_KEY_ID=$S3_PROTOCOL_ACCESS_KEY_ID \+AWS_SECRET_ACCESS_KEY=$S3_PROTOCOL_ACCESS_KEY_SECRET \+aws s3 ls \+--endpoint-url http://localhost:8000/storage/v1/s3 \+--region $REGION \+s3://your-storage-bucket )+```++{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+### Test with rclone+```bash+( set -a && \+source .env > /dev/null 2>&1 && \+echo "" && \+rclone ls \+--s3-endpoint http://localhost:8000/storage/v1/s3 \+--s3-region $REGION \+--s3-provider Other \+--s3-access-key-id "$S3_PROTOCOL_ACCESS_KEY_ID" \+--s3-secret-access-key "$S3_PROTOCOL_ACCESS_KEY_SECRET" \+:s3:your-storage-bucket )+```++Use `aws login` and `rclone config` for persistent configuration.++## How to configure an S3 backend++In general, the following configuration variables define S3 backend configuration for Storage in `docker-compose.yml`:++```yaml+storage:+ environment:+ # ... existing variables ...+ STORAGE_BACKEND: s3+ GLOBAL_S3_BUCKET: your-s3-bucket-or-dirname+ GLOBAL_S3_ENDPOINT: https://your-s3-endpoint+ GLOBAL_S3_PROTOCOL: https+ GLOBAL_S3_FORCE_PATH_STYLE: "true"+ AWS_ACCESS_KEY_ID: your-access-key-id+ AWS_SECRET_ACCESS_KEY: your-secret-access-key+ REGION: your-region+```++{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+Depending on your setup, you may need to adjust these values - for example, to use a local S3-compatible service like MinIO or a cloud provider like AWS.++{/* supa-mdx-lint-disable-next-line Rule001HeadingCase */}+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+### Using MinIO+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+An overlay `docker-compose.s3.yml` configuration can be added to enable MinIO container and provide an S3-compatible API for Storage backend:++```bash+docker compose -f docker-compose.yml -f docker-compose.s3.yml up -d+```++Make sure to review the Storage section in your `.env` file for related configuration options.++### Using AWS S3++Create an S3 bucket and an IAM user with access to it. Then configure the storage service:++```yaml docker-compose.yml+storage:+ environment:+ # ... existing variables ...+ STORAGE_BACKEND: s3+ GLOBAL_S3_BUCKET: your-aws-bucket-name+ AWS_ACCESS_KEY_ID: your-aws-access-key+ AWS_SECRET_ACCESS_KEY: your-aws-secret-key+ REGION: your-aws-region+```++For AWS S3, you do not need `GLOBAL_S3_ENDPOINT` or `GLOBAL_S3_FORCE_PATH_STYLE` - the Storage S3 client automatically resolves the endpoint from the region and uses virtual-hosted-style URLs, which is what AWS S3 expects. These variables are only needed for non-AWS S3-compatible providers.++### S3-compatible providers+{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+Use the same configuration as MinIO, but point to your provider's endpoint, e.g.:++```yaml+storage:+ environment:+ # ... existing variables ...+ STORAGE_BACKEND: s3+ GLOBAL_S3_BUCKET: your-bucket-name+ GLOBAL_S3_ENDPOINT: https://your-account-id.r2.cloudflarestorage.com+```++## Verify++{/* supa-mdx-lint-disable-next-line Rule003Spelling */}+- Open Studio and upload a file to a bucket. List the file using the AWS CLI or `rclone` to confirm the S3 endpoint works.+- If using an S3 backend: confirm the file appears in your S3 provider's console.++## Troubleshooting++### Signature mismatch errors++S3 clients sign requests using the access key ID and secret. If you see `SignatureDoesNotMatch`, verify that the `REGION`, `S3_PROTOCOL_ACCESS_KEY_ID` and `S3_PROTOCOL_ACCESS_KEY_SECRET` in your `.env` file match what your S3 client is using.++### TUS upload errors on Cloudflare R2++If resumable (TUS) uploads fail with HTTP 500 and a message about `x-amz-tagging`, add `TUS_ALLOW_S3_TAGS: "false"` to the storage service environment. Cloudflare R2 does not implement this S3 feature.++### Permission denied on uploads++Setting a bucket to "Public" only allows unauthenticated **downloads**. Uploads are always blocked unless you create an RLS policy on the `storage.objects` table. Go to **Storage** > **Files** > **Policies** in Studio and create a policy that allows `INSERT` for the appropriate roles.++### Upload URLs point to localhost++If uploads from a browser fail (CORS or mixed content errors), check that `API_EXTERNAL_URL` and `SUPABASE_PUBLIC_URL` in your `.env` file match your actual domain and protocol - not `http://localhost:8000`.++### Additional resources++- [Storage repository `.env.sample`](https://github.com/supabase/storage/blob/master/.env.sample)+- [S3 Authentication](/docs/guides/storage/s3/authentication)