---
title: "Laravel S3 Image Proxy: Clean URLs with CDN Caching"
url: https://daily.dev/posts/laravel-s3-image-proxy-clean-urls-with-cdn-caching-mxuxmu0hk
source_url: https://danielpetrica.com/how-to-replace-raw-s3-urls-with-a-laravel-image-proxy-and-keep-your-cdn-cache
type: article
source: "Daniel Petrica"
author: "Daniel, Petrica Andrei-Daniel"
published: 2026-06-15T15:56:34.695Z
updated: 2026-06-16T12:00:17.826Z
tags: ["laravel", "cloudflare", "aws-s3"]
reading_time: 4
upvotes: 7
comments: 1
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Laravel S3 Image Proxy: Clean URLs with CDN Caching

**[Daniel Petrica](https://daily.dev/sources/danielpetrica)** · [@danielpetrica](https://daily.dev/danielpetrica) · 4 min read · 7 upvotes · 1 comments

## Summary

A practical walkthrough for replacing raw S3 bucket URLs with clean, proxied paths in a Laravel application. The approach uses a centralized URL helper class and a streaming proxy controller (~20 lines) that serves files from private or public S3-compatible buckets via `/storage/{disk}/{path}` routes. Key benefits include hiding storage provider details, supporting private buckets without signed URLs, and setting 24-hour CDN cache headers via Cloudflare. The post also covers middleware adjustments to avoid overriding custom Cache-Control headers and notes the memory advantage of `readStream()` over `Storage::download()`.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://danielpetrica.com/how-to-replace-raw-s3-urls-with-a-laravel-image-proxy-and-keep-your-cdn-cache>

---

Tags: [#laravel](https://daily.dev/tags/laravel), [#cloudflare](https://daily.dev/tags/cloudflare), [#aws-s3](https://daily.dev/tags/aws-s3)

[View this post on daily.dev](https://daily.dev/posts/laravel-s3-image-proxy-clean-urls-with-cdn-caching-mxuxmu0hk)
