favicons 1.2.0

Privacy-first favicon and logo API: any site's icon as a clean, sandboxed SVG with light and dark theme colours
# Every key is optional; the values below are the defaults unless marked otherwise.
# Any key can be overridden with an environment variable:
#   FAVICONS_<SECTION>__<KEY>, e.g. FAVICONS_CACHE__STORAGE=s3://bucket/icons

[server]
listen = "0.0.0.0:8080"
# admin_listen = "127.0.0.1:9090"   # /metrics and /healthz; keep private
max_connections = 4096
max_concurrent_requests = 512
request_timeout_ms = 5000
header_read_timeout_ms = 5000
shutdown_grace_ms = 10000
# worker_threads = 2     # async runtime threads; default is one per CPU. Lower it on a box shared with other services
landing = true          # serve the demo page at / (only in builds with the "site" feature, e.g. the favicons.page image)
# public_url = "https://favicons.example.com"  # name and canonical URLs on the page; defaults to tls.domains[0], then the Host header

[client_ip]
# peer | x-forwarded-for | x-real-ip | cf-connecting-ip
# Only change this when a trusted reverse proxy sets the header.
source = "peer"
trusted_hops = 1        # for x-forwarded-for: how many proxies append to the header
ipv4_prefix = 24        # clients are grouped by subnet for limits and fairness
ipv6_prefix = 56

[rate_limit]
requests_per_second = 50.0   # per subnet; 0 disables
burst = 400.0
cached_cost = 0.05           # share of a token a cached icon costs; a miss pays the full token
max_tracked_clients = 100000

[fetch]
workers = 8
queue_capacity = 10000
per_client_queue_capacity = 64
wait_ms = 1500                # how long a cache miss may wait for the fetch
connect_timeout_ms = 3000
request_timeout_ms = 8000
dns_timeout_ms = 2000
job_timeout_ms = 25000
max_html_bytes = 131072        # stream stops at </head> or <body>, or at this cap
max_manifest_bytes = 65536
max_icon_bytes = 1048576
max_redirects = 4
max_candidates = 6
# Every URL the service connects to (pages, manifests, icons, redirect hops,
# upstream providers, blocklists, RDAP, the catalog) must pass these three.
# Startup fails if a configured URL doesn't.
allow_http = false            # plain http:// at all
allowed_ports = [443]         # e.g. [80, 443] together with allow_http = true
allow_ip_hosts = false        # links or redirects to https://203.0.113.7/; public addresses only even when true

[render]
# process  each image is decoded in a fresh seccomp-confined child process (default)
# socket   send images to `favicons render-server` (e.g. a container with no network)
# off      decode in-process (not recommended)
sandbox = "process"
socket_path = "/run/favicons/render.sock"
worker_memory_bytes = 268435456
# Largest source bitmap used for tracing; larger ones are downscaled first.
# Tracing itself runs on a 512 px resample with a palette of up to 12 colours.
trace_max_px = 256
max_output_svg_bytes = 49152
# Max mean difference between a site's SVG and our sanitized copy before tracing instead.
svg_fidelity = 0.02
decode_concurrency = 2
decode_timeout_ms = 5000
max_source_dimension = 1024
max_alloc_bytes = 33554432
max_svg_bytes = 262144
max_svg_depth = 48
svg = true

[cache]
# none                      memory only (lost on restart)
# /var/cache/favicons       local directory (also file:///var/cache/favicons)
# s3://bucket/prefix        S3 or any S3-compatible store (MinIO, R2, Ceph, …)
# gs://bucket/prefix        Google Cloud Storage
# az://container/prefix     Azure Blob Storage
storage = "none"
ttl_secs = 604800             # real icons are refreshed after 7 days
not_found_ttl_secs = 86400
fetch_failed_ttl_secs = 3600
too_new_ttl_secs = 86400
blocked_ttl_secs = 86400      # domains sinkholed by the filtering DNS resolver
memory_max_bytes = 67108864   # hot in-memory image cache
memory_meta_entries = 100000
memory_ttl_secs = 600
absent_ttl_secs = 60
storage_timeout_ms = 2000
# Caps for a local directory, counted as allocated disk space (a 2 KB icon takes
# a 4 KB block). Over a cap, the least recently used domains are deleted until
# usage is back under 90% of it. 0 means no cap. Object storage: use lifecycle rules.
max_disk_bytes = 0            # e.g. 5_000_000_000
max_disk_entries = 0          # domains

# Passed straight to object_store; see its docs for all keys.
[cache.options]
# aws_region = "eu-central-1"
# aws_endpoint = "https://s3.eu-central-1.amazonaws.com"
# aws_access_key_id = "…"          # prefer FAVICONS_CACHE__OPTIONS__AWS_ACCESS_KEY_ID
# aws_secret_access_key = "…"

[http_cache]
# gzip: stored icons are kept gzipped on disk and in memory and sent as is to
# clients that accept gzip (every browser and CDN); others get them unpacked.
# Generated fallbacks are never compressed. off: everything is stored and sent raw.
compression = "gzip"

# Each profile sets the browser Cache-Control and the CDN-Cache-Control (RFC 9213).
[http_cache.icon]
browser = "public, max-age=604800, stale-while-revalidate=86400"
cdn = "public, max-age=2592000, stale-while-revalidate=604800, stale-if-error=604800"

[http_cache.canonical]           # 301 from non-canonical URLs to /{style}/{domain}
browser = "public, max-age=2592000, immutable"
cdn = "public, max-age=31536000, immutable"

[http_cache.fallback_transient]   # queued, overloaded, fetch-failed; keep short so a flood is not cached
browser = "public, max-age=10"
cdn = "public, max-age=10"

[http_cache.fallback_stable]      # not-found, blocklisted, domain-too-new, invalid-domain
browser = "public, max-age=86400"
cdn = "public, max-age=86400, stale-if-error=86400"

[http_cache.error]
browser = "no-store"
cdn = "no-store"

[policy]
collapse_private_suffixes = true
deny_suffixes = ["onion", "arpa", "i2p"]
# Local paths or URLs; hosts, adblock (||domain^) and plain-domain formats.
blocklists = []
allowlist = []
reload_secs = 21600
max_list_bytes = 67108864
# Also applied to every foreign host an icon, manifest or redirect points to. 0 disables.
min_domain_age_days = 30
unknown_domain_age = "allow"   # allow | block when RDAP has no answer
rdap_bootstrap_url = "https://data.iana.org/rdap/dns.json"

[dns]
# cloudflare-security  1.1.1.2 / 1.0.0.2, Cloudflare with malware blocking (default)
# quad9                9.9.9.9, malware blocking as well
# cloudflare | google  no filtering
# system               OS resolver config (plain DNS)
# custom               your own servers below
provider = "cloudflare-security"
protocol = "https"            # https (DoH, port 443) | tls (DoT, port 853) | udp
# servers = ["194.242.2.2"]   # for provider = "custom"
# server_name = "dns.mullvad.net"
path = "/dns-query"
cache_size = 8192
max_ttl_secs = 3600

[bimi]
# Look up the domain's BIMI record (default._bimi.<domain> TXT, over the DoH
# resolver above) and use the logo the owner publishes for mail clients. It is
# tried before anything else and goes through the usual checks and sanitizer.
enabled = true

[catalog.thesvg]
# Curated brand SVGs from theSVG (https://github.com/GLINCKER/thesvg). The index
# is re-downloaded every reload_secs; icons are fetched lazily, one at a time.
# A domain matches only when the entry's url points at that site's root.
enabled = false
index_url = "https://raw.githubusercontent.com/GLINCKER/thesvg/main/src/data/icons.json"
asset_base = "https://raw.githubusercontent.com/GLINCKER/thesvg/main/public/"
# Licenses are per icon in theSVG. CC0 needs no attribution. Adding "MIT" or
# "Apache-2.0" also requires you to credit the authors where you show the icons.
licenses = ["CC0-1.0"]       # e.g. ["CC0-1.0", "Unlicense", "MIT", "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause", "CC-BY-4.0", "CC-BY-3.0"]
collections = ["brands"]
reload_secs = 86400
max_index_bytes = 16777216

# Optional icon catalogs addressed by slug instead of domain:
# GET /color/{id}/{slug}. Icons go through the same checks, sanitizer, palettes
# and caches as domains; an unknown slug is a 404 and never reaches the network.
# /catalogs.json and /catalogs/{id}.json list them. Formats: selfhst,
# simple-icons (tinted with each brand's colour), dashboard-icons, devicon,
# thesvg (licensed per icon; `licenses` keeps only the ones listed) and iconify
# (any Iconify JSON set, with an optional `mono_index_url`). Iconify catalogs
# are prerendered: with a cache storage configured, every icon goes through the
# usual pipeline into the cache in the background, then the source SVGs leave
# memory; unchanged icons are skipped on the next reload and prerendered entries
# are never evicted. `prerender = false` keeps the sources in memory and renders
# on first request instead. `license`
# is sent as X-Icon-License unless the index has one per icon.
# [[catalogs]]
# id = "selfhst"
# name = "selfh.st icons"
# format = "selfhst"
# index_url = "https://cdn.jsdelivr.net/gh/selfhst/icons@main/index.json"
# base_url = "https://cdn.jsdelivr.net/gh/selfhst/icons@main/"
# license = "CC-BY-4.0"
# attribution = "https://selfh.st/icons/"
#
# [[catalogs]]                      # Iconify JSON: SVGs come straight from the index
# id = "fluent-emoji"
# name = "Fluent Emoji"
# format = "iconify"
# index_url = "https://cdn.jsdelivr.net/npm/@iconify-json/fluent-emoji-flat/icons.json"
# mono_index_url = "https://cdn.jsdelivr.net/npm/@iconify-json/fluent-emoji-high-contrast/icons.json"
# base_url = "https://cdn.jsdelivr.net/npm/@iconify-json/fluent-emoji-flat/"
# license = "MIT"
# attribution = "https://github.com/microsoft/fluentui-emoji"
#
# [[catalogs]]
# id = "simple-icons"
# name = "Simple Icons"
# format = "simple-icons"
# index_url = "https://cdn.jsdelivr.net/npm/simple-icons@16/data/simple-icons.json"
# base_url = "https://cdn.jsdelivr.net/npm/simple-icons@16/"
# license = "CC0-1.0"
# attribution = "https://simpleicons.org"
#
# [[catalogs]]
# id = "dashboard-icons"
# name = "Dashboard Icons"
# format = "dashboard-icons"
# index_url = "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@main/metadata.json"
# base_url = "https://cdn.jsdelivr.net/gh/homarr-labs/dashboard-icons@main/"
# license = "Apache-2.0"
# attribution = "https://github.com/homarr-labs/dashboard-icons"
#
# [[catalogs]]
# id = "devicon"
# name = "Devicon"
# format = "devicon"
# index_url = "https://cdn.jsdelivr.net/gh/devicons/devicon@master/devicon.json"
# base_url = "https://cdn.jsdelivr.net/gh/devicons/devicon@master/"
# license = "MIT"
# attribution = "https://devicon.dev"
#
# [[catalogs]]
# id = "thesvg"
# name = "theSVG"
# format = "thesvg"
# index_url = "https://raw.githubusercontent.com/GLINCKER/thesvg/main/src/data/icons.json"
# base_url = "https://raw.githubusercontent.com/GLINCKER/thesvg/main/public/"
# license = "per icon"
# licenses = ["CC0-1.0", "Unlicense", "MIT", "Apache-2.0", "BSD-2-Clause", "BSD-3-Clause", "CC-BY-4.0", "CC-BY-3.0"]
# attribution = "https://github.com/GLINCKER/thesvg"

[upstream]
# Optional third-party sources, tried in order only when the site itself has no
# usable icon or cannot be reached. {domain} is replaced by the registrable
# domain. Each URL must be https and passes the same checks as any foreign host
# (SSRF rules, blocklists, domain age, DNS filter, every redirect hop). The image
# is traced into our own SVG in the sandbox; responses are never passed through.
# Once a day each provider is asked about a domain that does not exist; an
# answer identical to that placeholder is skipped.
#
# Privacy: the domain is sent to that service. Disabled by default.
#
# EXAMPLES ONLY. These are third-party services with their own terms of use,
# which may not allow this kind of access. Check their terms before enabling
# one, or point this at a service you run yourself.
providers = []
# providers = [
#   "https://favicon.vemetric.com/{domain}?size=256&format=webp",
#   "https://icons.duckduckgo.com/ip3/{domain}.ico",
#   "https://www.google.com/s2/favicons?domain={domain}&sz=64",
# ]

[identicon]
# Change to make generated icons unique to your deployment.
salt = ""

[tls]
# Serve HTTPS directly, with certificates from Let's Encrypt (ACME http-01).
# The plain listener in [server] keeps working; point it at localhost if
# everything should go through HTTPS.
enabled = false
listen = "[::]:443"
http_listen = "[::]:80"           # answers ACME challenges, redirects the rest to https://domains[0]
domains = []                      # e.g. ["favicon.example.com"]
contact = []                      # e.g. ["mailto:ops@example.com"]
directory = "https://acme-v02.api.letsencrypt.org/directory"
# directory = "https://acme-staging-v02.api.letsencrypt.org/directory"   # for testing
# directory_ca = "/etc/favicons/acme-root.pem"   # trust a private ACME server, e.g. Pebble
state_dir = "/var/lib/favicons/acme"            # account, key and certificate; keep it across restarts
renew_before_days = 30
# cert = "/etc/favicons/origin.pem"   # use a fixed certificate (e.g. Cloudflare Origin CA) instead of ACME
# key = "/etc/favicons/origin.key"