Problem: GIF files in /uploads/gifs/ were returning 404 errors even
though they existed on the backend server. Videos in /uploads/videos/
worked correctly.
Root cause: nginx location block order issue
- Line 64: Regex location ~* \.(gif|...) matched ALL .gif files
- This tried to serve GIFs from frontend dist/ directory (404)
- Line 49: /uploads/ proxy never executed for .gif files
The regex location block had higher priority than the prefix location
block, causing nginx to look for GIFs in the wrong directory.
Solution: Exclude /uploads/ path from static asset caching regex
- Changed regex from: ~* \.(js|css|...|gif|...)$
- To: ~* ^/(?\!uploads/).*\.(js|css|...|gif|...)$
- This uses negative lookahead to skip files under /uploads/
- Now /uploads/*.gif files are proxied to backend correctly
Also moved the static assets location block BEFORE the catch-all
location / block for better clarity (doesn't affect behavior).
Testing:
- nginx -t: configuration syntax OK
- Docker container starts successfully
- /uploads/videos/*.mp4 still work (proxied to backend)
- /uploads/gifs/*.gif now work (proxied to backend)
- Frontend static assets still cached (served from dist/)
This fixes the 404 errors for GIF preview images on production.
Co-Authored-By: Auggie