Proxy ActiveStorage through Rails instead of redirecting to internal MinIO URL #42
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "41-fix-broken-images-proxy-activestorage-th"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
ActiveStorage's default
redirectmode sends a 302 tominio.minio.svc.cluster.local:9000, which is a cluster-internal address the browser can't resolve. This makes all uploaded images appear broken.Changes
config.active_storage.resolve_model_to_route = :rails_storage_proxyinconfig/environments/production.rbTest Plan
/uploadsindex (thumbnails)/uploads/:idshow page (full-size)Review Checklist
Related Notes
Closes #41
PR #42 Review
DOMAIN REVIEW
Stack: Ruby on Rails (ActiveStorage configuration)
This is a single-line Rails config change in
config/environments/production.rb:Correctness: The setting is the correct Rails API for switching ActiveStorage from redirect mode (
:rails_storage_redirect, the default) to proxy mode (:rails_storage_proxy). This is the documented fix for environments where the storage backend (MinIO in this case) is not directly reachable by the browser -- exactly the situation described in the issue whereminio.minio.svc.cluster.local:9000is a cluster-internal address.Placement: The line is correctly placed in
production.rbonly, directly adjacent to theconfig.active_storage.serviceline (line 24). Development uses:localstorage (no MinIO), and test uses:teststorage, so neither environment needs this setting. Good scoping.Performance consideration (non-blocking): Proxy mode means Rails will stream every file download through the application server instead of issuing a redirect. For a landscaping app with photo uploads, this adds load to the Rails process. This is a known and accepted tradeoff for cluster-internal object stores. If file sizes or traffic grow significantly, consider putting a CDN or nginx proxy in front, but that is a future concern, not a blocker for this PR.
Security: Proxy mode routes file serving through the full Rails middleware stack, including any authentication. This is actually slightly more secure than redirect mode, which hands off a presigned URL. No concerns here.
BLOCKERS
None.
This is a one-line config change using a well-documented Rails API. It introduces no new functionality requiring test coverage -- it changes the transport mechanism for an existing feature. The BLOCKER criteria (missing tests for new functionality, unvalidated input, secrets, DRY violations in auth) do not apply.
NITS
Rails.application.config.active_storage.resolve_model_to_route == :rails_storage_proxyin production would catch accidental reverts. Very minor -- the test plan covers this through manual deployment verification, which is appropriate for a config-only change.SOP COMPLIANCE
41-fix-broken-images-proxy-activestorage-threferences issue #41Closes #41present for auto-close on mergePROCESS OBSERVATIONS
VERDICT: APPROVED