pig.py/Caddyfile.direct
Russell Ballestrini 6dab26d6fa Initial neopig: async media crawler with MD5 deduplication
- Multi-target concurrent crawling support
- Content-addressable vault storage (MD5 hash)
- SQLite database with page context for searchability
- Live SERP with real-time polling feed (/live)
- URI naming convention (media_uri, page_uri)
- GIF and image object-fit: contain for proper display
2025-12-21 17:26:42 -05:00

56 lines
1.3 KiB
Text

# neopig SERP - Direct vault serving (fastest)
#
# Caddy serves media files directly from vault, bypassing Python.
# Only API/search goes through FastAPI.
#
# Run: caddy run --config Caddyfile.direct
{
order rewrite before file_server
}
:8080 {
log {
output stdout
format console
}
# Direct media serving from vault
# URL: /media/abc123def... -> vault/ab/abc123def...
handle /media/* {
# Strip /media/ prefix
uri strip_prefix /media
# Map hash to vault subdirectory structure
# First 2 chars of hash = subdirectory
map {path} {vault_subdir} {
~^/([a-f0-9]{2}) "${1}"
default ""
}
# Rewrite to vault path
@hasSubdir expression {vault_subdir} != ""
rewrite @hasSubdir /vault/{vault_subdir}{path}
# Immutable cache headers (1 year)
header Cache-Control "public, max-age=31536000, immutable"
header X-Served-By "caddy-direct"
# Serve files
file_server {
root .
hide .git
}
}
# API requests -> FastAPI
handle /api/* {
header Cache-Control "no-cache, no-store"
reverse_proxy localhost:8000
}
# UI -> FastAPI
handle {
reverse_proxy localhost:8000
}
}