# Connect Vultr Object Storage to WordPress

To offload WordPress media to Vultr Object Storage, install Offloft, add an Object Storage subscription and a bucket, then copy the subscription keys into Offloft. These keys reach every bucket in the subscription, so keep this site separate. Offloft tests the connection and delivery before serving anything.

## 1. Create the storage and the bucket

In the Vultr customer portal, go to **Products > Cloud Storage > Object Storage** and add an Object Storage subscription in the region closest to most of your visitors.

Open the subscription, go to the **Buckets** tab and select **Create Bucket**. **Name:** lowercase letters, numbers and hyphens.

In Offloft, enter the region part of the subscription's hostname, for example ewr1 for ewr1.vultrobjects.com.

Bucket name:

```
my-site-media
```

## 2. Copy the access keys

Open the Object Storage subscription. Its **Overview** page shows the **Hostname**, the **Access Key** and the **Secret Key**; copy the two keys into Offloft.

*These keys reach every bucket in the subscription.* Keep a separate subscription for this site if you store other things in Vultr.

## 3. Let visitors read the files

Files are private unless each file is marked public. Offloft marks every file it uploads as public; the delivery check confirms it works.

If you prefer to make the whole bucket readable instead, apply the bucket policy below with s3cmd or the AWS CLI (put-bucket-policy). It lets anyone read a file whose address they know; nobody can list or change files.

Bucket policy:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PublicReadGetObject",
      "Effect": "Allow",
      "Principal": "*",
      "Action": ["s3:GetObject"],
      "Resource": ["arn:aws:s3:::my-site-media/*"]
    }
  ]
}
```

## 4. Serve files from your own domain with Vultr CDN (optional)

In the portal, go to **Products > CDN** and add a **Pull Zone**. Use https://my-site-media.your-region.vultrobjects.com as the origin address.

Add media.yoursite.com as the zone's custom domain and, at your DNS provider, point it (CNAME) to the address Vultr shows for the zone.

In Offloft, use https://media.yoursite.com as the delivery address.

Origin address:

```
https://my-site-media.your-region.vultrobjects.com
```

Delivery address:

```
https://media.yoursite.com
```

## 5. Allow your site to read files (CORS) (optional)

This step is optional. Images on your pages load without it. You need it only when your site's own scripts read files from storage, for example image editors, web fonts or 3D viewers. The rule below lets only your site read files, and only read them.

Vultr sets CORS through its S3 API. With the AWS CLI configured for these keys, run the command below.

AWS CLI command:

```
aws s3api put-bucket-cors --bucket my-site-media --endpoint-url https://your-endpoint --cors-configuration '{"CORSRules":[{"AllowedOrigins":["https://yoursite.com"],"AllowedMethods":["GET","HEAD"],"AllowedHeaders":["*"],"MaxAgeSeconds":3600}]}'
```

## Permissions Offloft needs

Vultr's keys reach every bucket in the subscription. Keep a separate subscription for this site if you store other things in Vultr.

## Serving your files

Files are private unless each file is marked public, and Offloft marks every file it uploads. To use your own domain, add a Vultr CDN pull zone with the bucket as its origin. The delivery check confirms visitors can load files.

## Questions

### What do I enter as the region?

The region part of the subscription hostname, for example ewr1 for ewr1.vultrobjects.com.

### Can I limit a key to one bucket?

Not with these keys. They reach every bucket in the subscription, so keep a separate subscription for this site if you store other things in Vultr.

### How do I use my own domain?

With Vultr CDN: add a pull zone with the bucket as its origin, add your domain, and point it at the address Vultr shows.

Source: https://www.offloft.com/setup/vultr
