Skip to content

370: Fix thumbnail 404 regression in nginx static-file location#408

Merged
turegjorup merged 1 commit into
feature/update-infrastructure-for-mono-repofrom
feature/370-fix-thumbnail-404
Apr 28, 2026
Merged

370: Fix thumbnail 404 regression in nginx static-file location#408
turegjorup merged 1 commit into
feature/update-infrastructure-for-mono-repofrom
feature/370-fix-thumbnail-404

Conversation

@turegjorup

Copy link
Copy Markdown
Contributor

Refs #370.

Summary

  • The regex location ~* \.(jpg|jpeg|png|gif|...) block in infrastructure/nginx/etc/templates/default.conf.template wins over location / for any URL ending in .jpg. It had no try_files directive, so nginx fell back to the default try_files $uri =404. First-time requests to /media/cache/resolve/<filter>/<path>.jpg 404'd without ever calling PHP, breaking LiipImagineBundle thumbnail generation.
  • One-line fix: add try_files $uri /index.php$is_args$args; to the static-file location so missing files hand off to Symfony, matching the implicit 2.6.1 behavior where everything flowed through location /.

Why nginx, not PHP

Putting thumbnail resolution into a PHP-layer file_get_contents on the resolve URL would block the response thread on synchronous image processing per item, add per-collection-item latency on serialization, and tightly couple the DTO output layer to image generation. The nginx fallback is request-routed by the proxy, runs once per missing thumbnail (cached on disk thereafter), and keeps the API contract clean.

Test plan

  • Rebuild the nginx image from this branch.
  • curl -I https://<host>/media/cache/resolve/thumbnail/<path>.jpg returns 302 (was 404).
  • Following the redirect returns 200 with Cache-Control: public, immutable.
  • A second request to the original resolve URL returns the same redirect; subsequent direct requests to the resolved path hit the disk-cached file.

🤖 Generated with Claude Code

The regex location for static files (jpg, png, etc.) had no try_files
directive, so first-time requests to /media/cache/resolve/... 404'd
without ever reaching Symfony. Adding the same fallback as location /
lets LiipImagineBundle generate missing thumbnails on demand.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@turegjorup
turegjorup requested a review from tuj April 28, 2026 09:23
@turegjorup turegjorup self-assigned this Apr 28, 2026
@turegjorup turegjorup added the bug Something isn't working label Apr 28, 2026
@turegjorup turegjorup added this to the 3.0.0 milestone Apr 28, 2026
@turegjorup
turegjorup merged commit c49aac4 into feature/update-infrastructure-for-mono-repo Apr 28, 2026
17 checks passed
@turegjorup
turegjorup deleted the feature/370-fix-thumbnail-404 branch April 28, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants