Skip to main content
Ayase Quart can serve media files (images, thumbnails, videos) from archives. The [media] section controls how media is accessed and delivered.

Basic media URIs

Define the base URIs for images and thumbnails:
image_uri
string
required
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}/image
thumb_uri
string
required
Base 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}/thumb
[media]
image_uri = "https://192.168.1.16:9001/static/ritual/{board}/image"
thumb_uri = "https://192.168.1.16:9001/static/ritual/{board}/thumb"
The {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.
serve_outside_static
boolean
default:"false"
Enable serving media files from outside the application’s static directory
media_root_path
string
default:""
Full path to the root media directory on your server.Example: If images are at /mnt/dl/<board>/image, set this to /mnt/dl
endpoint
string
default:"/srv/media"
URL endpoint prefix for serving media. Content will be served at /<endpoint>/<board>/image.Example: /srv/media serves from /srv/media/{board}/image
valid_extensions
array
default:"['jpg', 'jpeg', 'png', 'gif', 'webm', 'mp4']"
Only serve files with these extensions from outside the static path. Security measure to prevent serving arbitrary files.

Configuration example

[media]
serve_outside_static = true
media_root_path = '/mnt/archive/media'
endpoint = '/srv/media'
valid_extensions = ['jpg', 'jpeg', 'png', 'gif', 'webm', 'mp4']

# Update URIs to use the custom endpoint
image_uri = "/srv/media/{board}/image"
thumb_uri = "/srv/media/{board}/thumb"
Ensure media_root_path has proper permissions and only contains files you want to serve publicly.

Per-board media control

You can restrict which boards serve images or thumbnails using whitelists:
boards_with_image
string
default:""
Comma-separated list of board shortnames that serve full images.
  • Empty string ('') - All boards serve images (default)
  • Specific boards - Only listed boards serve images
Example: 'a,g,v' - Only /a/, /g/, and /v/ serve images
boards_with_thumb
string
default:""
Comma-separated list of board shortnames that serve thumbnails.
  • Empty string ('') - All boards serve thumbnails (default)
  • Specific boards - Only listed boards serve thumbnails
Example: 'a,g,v,tv' - Only /a/, /g/, /v/, and /tv/ serve thumbnails

Example configurations

[media]
image_uri = "https://archive.example.com/{board}/image"
thumb_uri = "https://archive.example.com/{board}/thumb"
boards_with_image = ''  # All boards
boards_with_thumb = ''  # All boards

Nginx sendfile optimization

For production deployments, use Nginx’s sendfile() to serve media efficiently without loading files into application memory.
use_nginx_sendfile
boolean
default:"false"
Enable Nginx X-Accel-Redirect for efficient media serving
nginx_x_accel_redirect_path
string
default:""
Internal Nginx location path for X-Accel-Redirect.Example: /x_accel_redirect1

Nginx configuration

  1. Configure Ayase Quart:
[media]
use_nginx_sendfile = true
nginx_x_accel_redirect_path = '/x_accel_redirect1'
image_uri = "https://archive.example.com/{board}/image"
thumb_uri = "https://archive.example.com/{board}/thumb"
  1. Add to your Nginx server block:
location /x_accel_redirect1/ {
    internal;
    alias /;  # Root media directory
    sendfile on;
    sendfile_max_chunk 1m;
    tcp_nopush on;
}
  1. User requests a media file from Ayase Quart
  2. Ayase Quart sends an X-Accel-Redirect header to Nginx with the file path
  3. Nginx serves the file directly using sendfile(), bypassing application memory
  4. 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

[media]
image_uri = "http://127.0.0.1:9001/static/{board}/image"
thumb_uri = "http://127.0.0.1:9001/static/{board}/thumb"
serve_outside_static = false
Media served directly from application’s static directory.

Security considerations

The valid_extensions setting prevents serving arbitrary files when using serve_outside_static.
valid_extensions = ['jpg', 'jpeg', 'png', 'gif', 'webm', 'mp4']
Only files with these extensions can be served from outside the static path.
  • 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
Ayase Quart validates file paths to prevent directory traversal attacks. The {board} placeholder is sanitized and validated against your boards configuration.

Troubleshooting

  • Verify image_uri and thumb_uri are not empty strings
  • Check board is in boards_with_image / boards_with_thumb if using whitelists
  • Ensure media files exist at the expected paths
  • Check filesystem permissions allow read access
  • Review browser console for 404 or 403 errors
  • Verify media_root_path is correct
  • Check file extensions match valid_extensions
  • Ensure board directories exist at {media_root_path}/{board}/
  • Verify endpoint configuration matches URI patterns
  • Verify Nginx location block is configured correctly
  • Check internal directive is present
  • Ensure alias path matches your media root
  • Review Nginx error logs for details
  • Test with use_nginx_sendfile = false first
  • 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_chunk is appropriate

Build docs developers (and LLMs) love