Deployment Options
- Hosted: use
https://crafatar.euphoriadevelopment.ukdirectly. - Self-hosted: deploy your own Crafatar instance with Docker or Node.js + Redis.
For endpoint and parameter reference, use Crafatar API Docs.
https://crafatar.euphoriadevelopment.uk directly.For endpoint and parameter reference, use Crafatar API Docs.
Recommended for production deployment.
docker network create crafatar
docker run --net crafatar -d --name redis redis
docker run --net crafatar \
-v crafatar-images:/home/app/crafatar/images \
-e REDIS_URL=redis://redis \
-e EXTERNAL_URL=https://crafatar.example.com \
-p 3000:3000 \
ghcr.io/<owner>/<repo>:latest
Service is then available at http://0.0.0.0:3000 behind your proxy/domain.
git clone https://github.com/EuphoriaTheme/crafatar.git
cd crafatar
npm install
cp .env.example .env
npm start
If node-canvas fails to build, install system dependencies from the official node-canvas installation guide.
Set these in .env:
REDIS_URL=redis://host:6379 (or rediss:// for TLS).PORT=3000, BIND=0.0.0.0.EXTERNAL_URL=https://crafatar.example.com for canonical public URL in docs/examples.CACHE_LOCAL=1200 and CACHE_BROWSER=3600 control freshness and browser cache lifetime.RETENTION_ENABLED=true, RETENTION_DAYS=30, RETENTION_INTERVAL_HOURS=24 for cleanup.REDIS_URL must use redis:// or rediss://. Invalid protocol disables Redis caching at startup.
server {
listen 443 ssl http2;
server_name crafatar.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
Crafatar reads forwarded headers to build correct external URLs when EXTERNAL_URL is not set.
curl -I "http://127.0.0.1:3000/avatars/069a79f444e94726a5befca90e38aaf5?size=64"
curl -I "http://127.0.0.1:3000/renders/head/069a79f444e94726a5befca90e38aaf5?scale=4"
200 and image/png for valid requests.422 for invalid UUID/size/scale/default values.CACHE_LOCAL or clear image cache/Redis keys.