[media] section controls how media is accessed and delivered.
Basic media URIs
Define the base URIs for images and thumbnails:Base URI for full-size images. Must contain
{board} placeholder.Set to empty string ('') to disable image serving entirely.Example: https://192.168.1.16:9001/static/ritual/{board}/imageBase URI for thumbnail images. Must contain
{board} placeholder.Set to empty string ('') to disable thumbnail serving entirely.Example: https://192.168.1.16:9001/static/ritual/{board}/thumbThe
{board} placeholder is replaced with the actual board shortname at runtime.Serving media outside static path
By default, media is served from the Quart app’s static directory (/path/to/ayase_quart/src/static). You can serve media from other filesystem locations.
Enable serving media files from outside the application’s static directory
Full path to the root media directory on your server.Example: If images are at
/mnt/dl/<board>/image, set this to /mnt/dlURL endpoint prefix for serving media. Content will be served at
/<endpoint>/<board>/image.Example: /srv/media serves from /srv/media/{board}/imageOnly serve files with these extensions from outside the static path. Security measure to prevent serving arbitrary files.
Configuration example
Per-board media control
You can restrict which boards serve images or thumbnails using whitelists:Comma-separated list of board shortnames that serve full images.
- Empty string (
'') - All boards serve images (default) - Specific boards - Only listed boards serve images
'a,g,v' - Only /a/, /g/, and /v/ serve imagesComma-separated list of board shortnames that serve thumbnails.
- Empty string (
'') - All boards serve thumbnails (default) - Specific boards - Only listed boards serve thumbnails
'a,g,v,tv' - Only /a/, /g/, /v/, and /tv/ serve thumbnailsExample configurations
Nginx sendfile optimization
For production deployments, use Nginx’ssendfile() to serve media efficiently without loading files into application memory.
Enable Nginx X-Accel-Redirect for efficient media serving
Internal Nginx location path for X-Accel-Redirect.Example:
/x_accel_redirect1Nginx configuration
- Configure Ayase Quart:
- Add to your Nginx server block:
How X-Accel-Redirect works
How X-Accel-Redirect works
- User requests a media file from Ayase Quart
- Ayase Quart sends an X-Accel-Redirect header to Nginx with the file path
- Nginx serves the file directly using
sendfile(), bypassing application memory - Result: Lower memory usage, better performance, reduced application load
The
internal directive ensures the X-Accel-Redirect location cannot be accessed directly by users.Media serving strategies
- Local development
- CDN deployment
- Nginx reverse proxy
- Network storage
Security considerations
File extension validation
File extension validation
The Only files with these extensions can be served from outside the static path.
valid_extensions setting prevents serving arbitrary files when using serve_outside_static.Filesystem permissions
Filesystem permissions
- Media directories should be readable by the application user
- Avoid write permissions unless necessary
- Use dedicated user account for the application
- Example:
chown -R ayase:ayase /mnt/archive
Path traversal prevention
Path traversal prevention
Ayase Quart validates file paths to prevent directory traversal attacks. The
{board} placeholder is sanitized and validated against your boards configuration.Troubleshooting
Images not loading
Images not loading
- Verify
image_uriandthumb_uriare not empty strings - Check board is in
boards_with_image/boards_with_thumbif using whitelists - Ensure media files exist at the expected paths
- Check filesystem permissions allow read access
- Review browser console for 404 or 403 errors
404 errors with serve_outside_static
404 errors with serve_outside_static
- Verify
media_root_pathis correct - Check file extensions match
valid_extensions - Ensure board directories exist at
{media_root_path}/{board}/ - Verify endpoint configuration matches URI patterns
Nginx sendfile not working
Nginx sendfile not working
- Verify Nginx location block is configured correctly
- Check
internaldirective is present - Ensure
aliaspath matches your media root - Review Nginx error logs for details
- Test with
use_nginx_sendfile = falsefirst
Slow media serving
Slow media serving
- Enable Nginx sendfile for production
- Consider using a CDN for large archives
- Check network latency if using network storage
- Monitor disk I/O performance
- Verify
sendfile_max_chunkis appropriate