# ----------------------------------------------------------------------- # nginx X-Accel-Redirect for artwork original file downloads # # Problem: PHP streams the file body through FPM → nginx, causing # "[warn] upstream response is buffered to a temporary file" # for large downloads because FastCGI buffers are too small. # # Solution: PHP sets X-Accel-Redirect, nginx serves the file body # directly from disk — FPM is only used for the header response. # # Setup: # 1. Set DOWNLOAD_ACCEL_PATH=/internal/originals in .env (production). # 2. Include this file inside your server {} block: # include /etc/nginx/conf.d/download-accel.conf; # 3. Make sure the nginx worker has read access to the originals path. # # The /internal/originals prefix MUST match DOWNLOAD_ACCEL_PATH in .env. # The alias path MUST match ARTWORKS_LOCAL_ORIGINALS_ROOT on the server. # ----------------------------------------------------------------------- location /internal/originals/ { # Block direct client access — only X-Accel-Redirect headers trigger this. internal; # Replace this with the actual absolute path to artwork originals on disk. # Typically: /var/www/skinbase/storage/originals or /var/www/skinbase/public/files/originals alias /var/www/skinbase/public/files/originals/; # Let nginx send the file efficiently with sendfile + tcp_nopush. sendfile on; tcp_nopush on; tcp_nodelay on; # No nginx-level caching for download responses (private files). add_header Cache-Control "private, no-store"; }