# How to install RustFS (S3) with Docker and Caddy on a VPS

**RustFS** is an Amazon S3-compatible object storage server written in Rust under the Apache 2.0 license, with a built-in web console. This tutorial deploys **RustFS `1.0.7`** on an Ubuntu 24.04 VPS using **Docker Compose** and **Caddy `2.11`**, exposing only the S3 API over HTTPS, keeping the web console bound to `127.0.0.1:9001` for SSH tunnel access, and verifying uploads, downloads, and persistence with `rclone`.

If you prefer to skip manual installation, [Nuvits](https://nuvits.net/en) also offers a [Dedicated S3 Storage VPS with RustFS preinstalled](https://nuvits.net/en/s3-storage-vps) under `/opt/rustfs`, with locally generated credentials in `/opt/rustfs/.env` and the `nuvits-rustfs-https` helper. To build and operate the stack yourself on any Linux VPS, follow the steps below.

## How much RAM and disk RustFS needs

Because RustFS compiles to a native Rust binary without a heavy JVM or garbage-collected runtime, idle memory usage stays small. During testing on Ubuntu 24.04 (`x86_64`) with RustFS `1.0.7` and Caddy `2.11` running and serving requests, `docker stats --no-stream` reported:

```text
NAME              MEM USAGE / LIMIT     CPU %
rustfs-caddy-1    60.67MiB / 7.817GiB   0.04%
rustfs-rustfs-1   61.06MiB / 7.817GiB   0.06%
```

Disk capacity and bandwidth matter far more than idle RAM. Use these tiers as a baseline:

| Workload                                                 | vCPU | RAM     | SSD Disk    |
| -------------------------------------------------------- | ---- | ------- | ----------- |
| Evolution API media, SaaS uploads, and daily n8n backups | 2    | 4 GB    | 300–400 GB  |
| Multiple apps, backup buckets, and 90-day retention      | 4–6  | 8–18 GB | 800 GB–1 TB |
| Central media store and backups across several servers   | 8+   | 24+ GB  | 1.2–1.4 TB  |

> **A single-VPS S3 server is not a substitute for off-site backups.** Everything lives on one virtual disk. Keep a secondary copy off this server for critical production media or database dumps.

## Secure Docker and Caddy architecture

Only Caddy publishes public ports (`80` and `443`). The S3 API port (`9000`) stays inside the private Docker Compose network, and the web console port (`9001`) binds strictly to loopback (`127.0.0.1:9001`) so you open it only through an SSH tunnel:

![Architecture of RustFS 1.0.7 with Docker Compose and Caddy on an Ubuntu VPS: Caddy on ports 80 and 443 proxying the S3 API to rustfs:9000 on the internal Docker network, while the Web Console stays bound to 127.0.0.1:9001 over an SSH tunnel](https://nuvits.net/blog/install-rustfs-s3-docker-caddy-vps/rustfs-s3-docker-caddy-vps-architecture.webp)

Three details prevent common production mistakes:

1. **Host directories owned by `10001:10001`:** the official RustFS image runs as UID/GID `10001`, not `root`. Plain `mkdir` folders owned by your user or `root` cause startup write errors on `/data`.
2. **Preserved `Host` header and `flush_interval -1` in Caddy:** S3 clients sign the `Host` header with AWS Signature V4 (`AWS4-HMAC-SHA256`). Caddy's `reverse_proxy` preserves `Host` by default, and `flush_interval -1` turns off response buffering for larger downloads.
3. **Web console isolated from the S3 API port:** in RustFS `1.0.7`, `/rustfs/console/` only responds on port `9001`. Requests to `https://s3.example.com/rustfs/console/` through port `9000` return `HTTP 403`.

## What you need

- A 64-bit **Ubuntu 24.04 VPS** with SSH access as a `sudo` user.
- A `ufw` firewall allowing only SSH, `80/tcp`, and `443` (TCP and UDP). If the server is brand new, apply [First steps to secure an Ubuntu 24.04 VPS](https://nuvits.net/en/blog/secure-ubuntu-24-04-vps) first.
- A subdomain with a DNS `A` record pointing to the VPS IPv4 address (`s3.example.com` below) and an email address for Caddy's Let's Encrypt account.

## Install Docker Engine

If Docker is already installed on your VPS, jump to the version check at the end of this section. Otherwise, install from the [official Docker Ubuntu repository](https://docs.docker.com/engine/install/ubuntu/):

```bash
sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker --version
sudo docker compose version
```

The output confirms Docker Engine and the Compose plugin are active (in our test VM, `Docker version 29.10.1` and `Docker Compose version v5.8.1`).

## Create directories and generate strong credentials

Create the project directory along with `data` and `logs` owned by `10001:10001`:

```bash
mkdir -p ~/rustfs && cd ~/rustfs
sudo install -d -m 750 -o 10001 -g 10001 data logs
```

Generate random root credentials before starting the container (leaving them unset falls back to the public default `rustfsadmin`/`rustfsadmin`, which must never be exposed):

```bash
echo "RUSTFS_ACCESS_KEY=s3_$(openssl rand -hex 12)"
echo "RUSTFS_SECRET_KEY=$(openssl rand -hex 24)"
```

Write `.env` with the generated values and restrict its file permissions:

```ini
RUSTFS_VERSION=1.0.7
S3_DOMAIN=s3.example.com
ACME_EMAIL=you@example.com
RUSTFS_ACCESS_KEY=paste-generated-access-key
RUSTFS_SECRET_KEY=paste-generated-secret-key
```

```bash
chmod 600 .env
ls -ld data logs .env
```

Verify that both folders belong to `10001` and `.env` is readable only by its owner:

```text
drwxr-x--- 1  10001  10001   0 Nov 28 09:29 data
-rw------- 1 deploy deploy 186 Nov 28 09:29 .env
drwxr-x--- 1  10001  10001   0 Nov 28 09:29 logs
```

> **Back up `.env` outside the VPS.** `RUSTFS_ACCESS_KEY` and `RUSTFS_SECRET_KEY` are the initial root credentials. Once the stack is up, create bucket-scoped access keys inside the Web Console for each application instead of sharing the root credentials.

## Write the `Caddyfile` and `docker-compose.yml`

The `Caddyfile` publishes only the S3 API hostname and lets [Caddy's reverse proxy](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy) obtain and renew the TLS certificate automatically:

```caddy
{
	email {$ACME_EMAIL}
}

{$S3_DOMAIN} {
	reverse_proxy rustfs:9000 {
		flush_interval -1
	}
}
```

Next, create `docker-compose.yml` pinning release `1.0.7` from the [official RustFS releases](https://github.com/rustfs/rustfs/releases), with `no-new-privileges:true`, healthchecks on both internal ports, and the console bound strictly to `127.0.0.1:9001`:

```yaml
services:
  caddy:
    image: caddy:2.11
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
      - "443:443/udp"
    environment:
      - S3_DOMAIN=${S3_DOMAIN}
      - ACME_EMAIL=${ACME_EMAIL}
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - caddy_data:/data
      - caddy_config:/config
    depends_on:
      rustfs:
        condition: service_healthy

  rustfs:
    image: rustfs/rustfs:${RUSTFS_VERSION}
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    ports:
      - "127.0.0.1:9001:9001"
    env_file:
      - .env
    environment:
      - RUSTFS_VOLUMES=/data
      - RUSTFS_ADDRESS=0.0.0.0:9000
      - RUSTFS_CONSOLE_ADDRESS=0.0.0.0:9001
      - RUSTFS_CONSOLE_ENABLE=true
      - RUSTFS_OBS_LOGGER_LEVEL=warn
    volumes:
      - ./data:/data
      - ./logs:/logs
    healthcheck:
      test:
        [
          "CMD-SHELL",
          "curl -fsS http://127.0.0.1:9000/health/ready && curl -fsS http://127.0.0.1:9001/rustfs/console/health",
        ]
      interval: 15s
      timeout: 5s
      retries: 10
      start_period: 15s

volumes:
  caddy_data:
  caddy_config:
```

> **Why `127.0.0.1:9001:9001` instead of `9001:9001`?** Docker inserts `DNAT` rules before `ufw`, so `9001:9001` exposes the console on the public interface even when the firewall is active. Prefixing `127.0.0.1:` restricts the listener to loopback. See [Why Docker ports stay open with ufw](https://nuvits.net/en/blog/docker-port-still-open-with-ufw) for the full mechanics.

## Validate, verify DNS, and start the stack

Validate both files before starting anything:

```bash
cd ~/rustfs
sudo docker compose config --quiet
sudo docker run --rm \
  -e S3_DOMAIN=s3.example.com \
  -e ACME_EMAIL=you@example.com \
  -v "$PWD/Caddyfile:/etc/caddy/Caddyfile:ro" \
  caddy:2.11 caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile
```

Caddy should print `Valid configuration`. Confirm that your DNS `A` record resolves to the VPS IPv4 (`dig +short s3.example.com A`), then bring the stack up:

```bash
sudo docker compose up -d
sudo docker compose ps
```

Caddy waits until `rustfs` reports `healthy`:

```text
NAME              IMAGE                 COMMAND                  SERVICE   CREATED          STATUS                    PORTS
rustfs-caddy-1    caddy:2.11            "caddy run --config …"   caddy     12 seconds ago   Up 5 seconds              0.0.0.0:80->80/tcp, [::]:80->80/tcp, 0.0.0.0:443->443/tcp, [::]:443->443/tcp, 0.0.0.0:443->443/udp, [::]:443->443/udp, 2019/tcp
rustfs-rustfs-1   rustfs/rustfs:1.0.7   "/etc/rustfs/entrypo…"   rustfs    13 seconds ago   Up 12 seconds (healthy)   9000/tcp, 127.0.0.1:9001->9001/tcp
```

## Verify health endpoints, HTTPS, and port isolation

Test the HTTP-to-HTTPS redirect and the S3 readiness endpoint:

```bash
curl -sS -I http://s3.example.com/health | head -n 6
curl -fsS https://s3.example.com/health/ready
```

Port 80 responds with `308 Permanent Redirect` to `https://`, and `/health/ready` returns `HTTP/2 200` with subsystem status (`iam`, `lock`, `poolMetadata`, and `storage`):

```json
{
  "degradedReasons": [],
  "details": {
    "iam": { "ready": true, "status": "connected" },
    "lock": { "ready": true, "status": "connected" },
    "poolMetadata": { "ready": true, "status": "writable" },
    "storage": {
      "missingDrives": [],
      "readQuorum": true,
      "readinessScope": "read_quorum",
      "ready": true,
      "source": "local_runtime",
      "status": "connected",
      "unavailableDrives": [],
      "writeQuorum": true
    }
  },
  "ready": true,
  "service": "rustfs-endpoint",
  "status": "ok",
  "version": "1.0.7"
}
```

Check the host's listening sockets and the local console health check:

```bash
sudo ss -tulpn | grep -E ':(80|443|9000|9001)\b'
curl -fsS http://127.0.0.1:9001/rustfs/console/health
```

Expected output:

```text
udp   UNCONN 0      0                   0.0.0.0:443       0.0.0.0:*    users:(("docker-proxy",pid=10863,fd=8))
udp   UNCONN 0      0                      [::]:443          [::]:*    users:(("docker-proxy",pid=10871,fd=8))
tcp   LISTEN 0      4096              127.0.0.1:9001      0.0.0.0:*    users:(("docker-proxy",pid=10667,fd=8))
tcp   LISTEN 0      4096                0.0.0.0:443       0.0.0.0:*    users:(("docker-proxy",pid=10848,fd=8))
tcp   LISTEN 0      4096                0.0.0.0:80        0.0.0.0:*    users:(("docker-proxy",pid=10834,fd=8))
```

Port `9000` is never published on the host, and port `9001` listens strictly on `127.0.0.1`. The console health endpoint answers `{"service":"rustfs-console","status":"ok","version":"1.0.7"}`.

### Open the Web Console over an SSH tunnel

From your workstation (not inside the VPS), open an SSH tunnel forwarding port `9001`:

```bash
ssh -N -L 9001:127.0.0.1:9001 deploy@YOUR_VPS_IP
```

If you moved SSH to a custom port (such as `2222` in the [Ubuntu 24.04 hardening guide](https://nuvits.net/en/blog/secure-ubuntu-24-04-vps)), include `-p 2222` in the command (`ssh -p 2222 -N -L 9001:127.0.0.1:9001 deploy@YOUR_VPS_IP`).

While that terminal remains open, visit `http://localhost:9001/rustfs/console/` in your browser (opening `http://localhost:9001/` in a browser also redirects with `302` to `/rustfs/console/`). Sign in using `RUSTFS_ACCESS_KEY` and `RUSTFS_SECRET_KEY` from `.env`, create your buckets, and issue scoped **Access Keys** limited to each application's buckets.

If you explicitly want the web console reachable without an SSH tunnel, add a second dedicated subdomain in the `Caddyfile` (`console-s3.example.com`) proxying to `rustfs:9001` rather than mixing console access onto the public S3 API domain.

## Test S3 operations end to end with `rclone`

To confirm that AWS SigV4 signing, object uploads, listing, and disk persistence work through Caddy, install the official [rclone](https://rclone.org/s3/) `.deb` package and run a full write, container recreation, and read-back test:

```bash
cd /tmp
curl -fsSLO "https://downloads.rclone.org/rclone-current-linux-$(dpkg --print-architecture).deb"
sudo apt install -y "./rclone-current-linux-$(dpkg --print-architecture).deb"
rclone version | head -n 1
```

Load the `.env` variables (or use a scoped key created in the Console) and create an S3 remote with `force_path_style=true`:

```bash
cd ~/rustfs
set -a && . ./.env && set +a

rclone config create rustfs-prod s3 provider=Other env_auth=false \
  access_key_id="$RUSTFS_ACCESS_KEY" \
  secret_access_key="$RUSTFS_SECRET_KEY" \
  endpoint="https://${S3_DOMAIN}" \
  region="us-east-1" \
  force_path_style=true > /dev/null
```

Create a bucket, generate a 1 MB random file, upload it to RustFS, and record its SHA-256 digest:

```bash
rclone mkdir rustfs-prod:app-media
rclone lsd rustfs-prod:

dd if=/dev/urandom of=/tmp/sample-1mb.bin bs=1M count=1 status=none
sha256sum /tmp/sample-1mb.bin
rclone copyto /tmp/sample-1mb.bin rustfs-prod:app-media/sample-1mb.bin
rclone ls rustfs-prod:app-media
```

Now recreate the containers (without `-v`) and download the object back to prove `./data` persists across restarts:

```bash
sudo docker compose down
sudo docker compose up -d
rclone copyto rustfs-prod:app-media/sample-1mb.bin /tmp/restored-1mb.bin
sha256sum /tmp/sample-1mb.bin /tmp/restored-1mb.bin
```

Both SHA-256 digests must match identically. Remove the test object with `rclone deletefile rustfs-prod:app-media/sample-1mb.bin` and clean up `/tmp`.

## Connect Evolution API, n8n backups, and Coolify

Once the HTTPS endpoint passes the check above, any S3-compatible client can write to your buckets using path-style URLs (`https://s3.example.com/<bucket>/<object>`).

### Evolution API (store WhatsApp media outside PostgreSQL)

In your [Evolution API Docker setup](https://nuvits.net/en/blog/install-evolution-api-docker-vps), point `.env` to a dedicated RustFS bucket (such as `evolution`) with a scoped key pair:

```ini
S3_ENABLED=true
S3_ACCESS_KEY=dedicated-evolution-access-key
S3_SECRET_KEY=dedicated-evolution-secret-key
S3_BUCKET=evolution
S3_PORT=443
S3_ENDPOINT=s3.example.com
S3_REGION=us-east-1
S3_USE_SSL=true
```

### n8n and Coolify backups

- **n8n:** the [Automatic n8n backups](https://nuvits.net/en/blog/n8n-automatic-backup) guide uses `rclone` with a `crypt` layer on top of an S3 remote. Pass `endpoint="https://s3.example.com"` and `force_path_style=true` when creating `n8n-s3` (pointing at a separate VPS from the n8n host so backups live off-box).
- **Coolify:** under **S3 Storages**, enter `https://s3.example.com`, the backup bucket name, region `us-east-1`, and a scoped key restricted to that bucket.

## Upgrades and common issues

### Upgrade RustFS without touching your buckets

1. Review the changelog on [RustFS GitHub releases](https://github.com/rustfs/rustfs/releases) and the [official RustFS docs](https://docs.rustfs.com/).
2. Update `RUSTFS_VERSION` in `.env` to the new stable tag.
3. Pull and recreate only the `rustfs` container:

```bash
cd ~/rustfs
sudo docker compose pull rustfs
sudo docker compose up -d rustfs
sudo docker compose logs --tail=30 rustfs
```

### Common issues

- **Container restarts in a loop with `Permission denied` on `/data` or `/logs`:** the directories belong to `root` or your login user instead of `10001:10001`. Fix ownership with `sudo chown -R 10001:10001 ~/rustfs/data ~/rustfs/logs` and run `sudo docker compose restart rustfs`.
- **`curl http://127.0.0.1:9001/` returns `403` or `501`:** port `9001` only redirects `/` when it receives browser headers (`Accept: text/html` and a browser `User-Agent`). Use `http://127.0.0.1:9001/rustfs/console/health` for CLI health checks and open `http://localhost:9001/rustfs/console/` in your browser.
- **`SignatureDoesNotMatch` or client errors:** make sure **path-style** addressing is enabled (`force_path_style=true` in `rclone`, `AWS_USE_PATH_STYLE_ENDPOINT=true` in Laravel/AWS SDK) whenever you expose a single subdomain (`s3.example.com`) without wildcard DNS (`*.s3.example.com`).
- **TLS certificate does not issue:** check that your DNS `A` record points to the VPS, confirm `80/tcp` and `443` are open in both `ufw` and any upstream network firewall, and inspect `sudo docker compose logs caddy`.

## Next steps

- If you want RustFS ready out of the box without setting up Docker and Caddy by hand, see [Dedicated S3 Storage VPS (RustFS)](https://nuvits.net/en/s3-storage-vps).
- If you have not hardened SSH, the firewall, and automatic updates yet, follow [First steps to secure an Ubuntu 24.04 VPS](https://nuvits.net/en/blog/secure-ubuntu-24-04-vps).
- To schedule encrypted workflow backups into your new bucket, read [Automatic n8n backups](https://nuvits.net/en/blog/n8n-automatic-backup).

---

*Originally published on the [Nuvits blog](https://nuvits.net/en/blog/install-rustfs-s3-docker-caddy-vps).*

