---
title: Deploy imgproxy with AI on Blossom
url: "/deploy/imgproxy/"
canonical_url: https://blossom88.com/deploy/imgproxy/
markdown_url: https://blossom88.com/deploy/imgproxy.md
summary: Deploy imgproxy with AI on Blossom. Resize images from a private Cloudflare
  R2 bucket, serve signed URLs, and cache images at the CDN.
categories:
- deployment
- images
stack:
- Go
- libvips
---

# Deploy imgproxy with AI on Blossom

[imgproxy](https://imgproxy.net/) resizes and optimizes images on demand.
Keep one original in object storage and request the size your page needs.

## Ask Your Agent

> **Ask your AI agent:** Deploy imgproxy on Blossom and help me resize images from my R2 bucket.
>
> Follow this guide: https://blossom88.com/deploy/imgproxy/

[Install the Blossom CLI and skill](https://docs.blossom88.com/learn/getting-started/install/) on your agent's machine and [choose a Location in your cloud account](https://docs.blossom88.com/learn/getting-started/choose-your-cloud/#connect-your-provider).

## Your Image Setup

| Part | Purpose |
|---|---|
| imgproxy | Image resizing on regular App Capacity |
| Your private R2 bucket | Original images |
| Cloudflare CDN | Cached image delivery |

Bring a bucket in your own Cloudflare account and an image domain. Give
imgproxy a bucket-restricted, read-only credential; use a separate credential
for uploads. Containers share the same bucket and signing keys.

<details class="optional-reading" markdown="1">
<summary>Deployment setup and commands</summary>

Your agent creates a private bucket in your Cloudflare account and a
[bucket-restricted, read-only credential](https://developers.cloudflare.com/r2/api/tokens/)
for imgproxy. Use a separate credential for uploading images. Keep both in
private environment files outside your application repository.

The Service uses regular App Capacity and needs no attached Volume or database.
Additional Containers can read the same bucket and use the same signing keys.

Your agent checks imgproxy's current
[installation](https://docs.imgproxy.net/installation) and
[S3 configuration](https://docs.imgproxy.net/image_sources/amazon_s3), selects
a maintained official image for your Location's architecture, and pins it in
the deployment configuration.

    blossom profile:show
    blossom app:create --data '{"app":{"name":"imgproxy"}}'

The agent writes environment.yml using the returned App ID:

```yaml
environment:
  app_id: app-100
  name: production
  source_type: prebuilt_image
  prebuilt_image: <official image pinned by your agent>
  access_mode: public
```

    blossom environment:create --data environment.yml

Save these settings in a private .env.production file. Generate stable,
hex-encoded `IMGPROXY_KEY` and `IMGPROXY_SALT` values using imgproxy's
[signing guidance](https://docs.imgproxy.net/usage/signing_url).

```dotenv
IMGPROXY_BIND=:8080
IMGPROXY_USE_S3=true
IMGPROXY_S3_ENDPOINT=<your R2 S3 endpoint>
IMGPROXY_S3_REGION=auto
IMGPROXY_S3_ENDPOINT_USE_PATH_STYLE=true
AWS_ACCESS_KEY_ID=<bucket-restricted read-only access key>
AWS_SECRET_ACCESS_KEY=<its secret access key>
IMGPROXY_ALLOWED_SOURCES=s3://my-blog-images/
IMGPROXY_S3_ALLOWED_BUCKETS=my-blog-images
IMGPROXY_KEY=<stable hex signing key>
IMGPROXY_SALT=<stable hex signing salt>
```

    blossom env_var:push --environment environment-100 --file .env.production

The agent creates service.yml with the `imgproxy` startup command, port
`8080`, and resources suited to your images and traffic. Use a Command health
check running `imgproxy health`; the official image provides this command.

```yaml
health_check:
  enabled: true
  kind: command
  command: CMD-SHELL imgproxy health
```

    blossom service:create --data service.yml
    blossom domain:create --data '{"domain":{"environment_id":"environment-100","dns_name":"imgproxy.example.com","main":true}}'
    blossom environment:deploy --id environment-100 --follow
    blossom environment:show --id environment-100

Use Blossom's returned DNS target for the image domain. Configure its origin
HTTPS mode to match your Cloudflare SSL settings.

</details>

## Serve the Size Your Page Needs

Upload a versioned original and generate signed URLs for thumbnails and larger
images. Add `srcset` and `sizes` to let the browser choose. Keep signing keys
on a trusted backend or build machine, outside browser JavaScript.

<details class="optional-reading" markdown="1">
<summary>Responsive images and original files</summary>

Upload each original under a unique, versioned object name. Your agent
generates signed URLs for the required sizes and adds `srcset` and `sizes`
to your image markup. The browser chooses a suitable size for the display.
Use `fit` resizing without enlargement to preserve the image's proportions.

![A blog article card using a smaller image served by imgproxy.](https://imgproxy.boltops.com/lhIGCTB4r_uEIoqDeGzxKPOJeNcnLncDjKmso24RQ5A/rs:fit:640:0:0/q:85/czM6Ly9ib2x0b3BzLWltZ3Byb3h5L29yaWdpbmFscy9iMGVlZGY5YWJjZmNhMDJlYmU1Mjg5NjljYzNkMmJkZGFjNzhlMzQ2N2EwMzJmMWZlZDZkMjc0OTRmYTg1YWE0L2Jsb2ctY2FyZC5wbmc.webp)

Generate signatures on a trusted machine or during your build. Keep signing
keys out of browser JavaScript. A signed `raw:1` URL can serve the original
bytes for full-size viewing.

Use explicit output formats such as WebP and verify Cloudflare caches the
image URLs. Versioned originals let a changed image get a new URL while
existing pages keep working.

</details>

<details class="optional-reading" markdown="1">
<summary>Updates and storage</summary>

blossom environment:deploy --id environment-100 --follow

Keep the bucket and signing keys when replacing Containers. Originals live
in R2, so a new Container can serve the same signed URLs.

</details>

## What You Get

- Images sized for thumbnails, article content, and larger displays
- Original files in your own private R2 bucket
- Signed image URLs cached by Cloudflare
- Stateless Containers that can be replaced or scaled without moving images
