> For the complete documentation index, see [llms.txt](https://bonusmastodon.aus.social/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bonusmastodon.aus.social/basics/static-content-cdn/bunny.net-cdn-pull-zone.md).

# Bunny.net CDN (Pull Zone)

## Stage 1: Setup Pull Zone&#x20;

### 1) Add new pull zone in Bunny.net

### 2) Create a unique name for the pullzone&#x20;

Example: `mastodoninstancestatic` or similar.

<figure><img src="/files/woPev23on9DIxfXLX5Hx" alt=""><figcaption></figcaption></figure>

### 3) Select `Origin Type URL`

### 4) Update **Origin URL**

Place the original FQDN of your instance in the Original URL.

<figure><img src="/files/X7LbAsFQnEI0DdgOcMQP" alt=""><figcaption></figcaption></figure>

### 5) Select your regions to replicate data

<figure><img src="/files/6ge5o9JO2RUSLKDxYHXA" alt=""><figcaption></figcaption></figure>

### 6) Add new Pull zone

## Stage 2: Configure Pull Zone.

### 1) Force SSL

<figure><img src="/files/e2rJ1XGRWiuG4uqjEJ0E" alt=""><figcaption></figcaption></figure>

### 2) Setup SafeHop (retries on failures)

<figure><img src="/files/20yQORyPsp9SjTwdi8PA" alt=""><figcaption></figcaption></figure>

### 3) Add additional Headers (CORS)

Add \`,js, gz\` to the Extension list.

Example: \`eot, ttf, woff, woff2, css, js, gz\`

<figure><img src="/files/TDAfgLIbM7oSaySaqDml" alt=""><figcaption></figcaption></figure>

## Stage 3: Configure Mastodon and NGINX

### 1) NGINX Headers

Add **`Access-Control-Allow-Origin`** header to nginx all locations.\
Example: `add_header Access-Control-Allow-Origin "https://aussocialstatic.b-cdn.net";`

<figure><img src="/files/hePqKFChjjWkDSK0qSEy" alt=""><figcaption><p>These paths are heavily used for static files... but the header might be required in multiple locations in the nginx conf</p></figcaption></figure>

### 2) Mastodon .env

Add `CDN_HOST` to .env.production&#x20;

Example: `CDN_HOST=https://aussocialstatic.b-cdn.net`

### 3) Reload nginx and restart mastodon.

## Troubleshooting

The OCR (Optical character recognition) might fail if you missed gz from the extension list.

<figure><img src="/files/UKEhnUIeMPdfFOn8XMoa" alt=""><figcaption></figcaption></figure>

## Notes

Do we need to add to svg to the CORs?
