Documentation
Getting started
From nothing to a federating instance. Most problems come from two places: the domain names and the reverse proxy.
The downloads directory has source archives and
ready-made executables in binaries/. Pick your operating system,
architecture and storage variant. The binaries already include blog support.
Check the source archive against its .sha256 file, or the binary
against binaries/SHA256SUMS, before using it.
Build it, or use a binary
If you downloaded an executable, make it executable and rename it to
littlefedi. For example, on a Linux amd64 machine:
chmod 755 littlefedi-linux-amd64
mv littlefedi-linux-amd64 littlefedi
There is no Go installation needed to run it. To build from source instead,
extract the source archive and run make build in that directory.
You need Go 1.27.4 or newer and GNU Make (gmake on BSD systems).
make build
The result is one static executable with CGO disabled. It has no shared library
dependencies, no interpreter, and no external database. You can build it on one
machine and copy it to another running the same operating system and architecture.
On platforms that use the SQLite fallback driver, such as illumos, NetBSD ARM
and the less common OpenBSD and Linux architectures, backups also need the
sqlite3 command.
Run the wizard
./littlefedi init # choose "instance"
./littlefedi --config littlefedi.toml
littlefedi init asks the questions that are hard to change later:
single-user or multi-user, the domains, the database, where media lives, whether
to join littleMesh, and the address of the reverse
proxy it should trust. It writes a complete littlefedi.toml, creates
the first administrator, and comments out everything you declined so the file
still documents it.
Then open http://localhost:8080 and sign in with that
administrator.
init already asked for the web_domain other
instances will use. Federation needs that domain served over public HTTPS, not a
direct connection to port 8080. Nothing federates until a proxy is in front.
Two domains, one server
Your handle can be @alice@example.com while the server runs at
social.example.com. Your existing website can stay on
example.com; it only needs one WebFinger redirect. For a proxy on
the same machine, use:
local_domain = "example.com"
web_domain = "social.example.com"
[http]
listen = "127.0.0.1:8080"
proxy_uri = "https://social.example.com"
trusted_proxies = ["127.0.0.1/32"]
local_domain is the domain in account handles, the thing people
type. web_domain serves the web interface, the API, media, and the
ActivityPub objects. Both domains need working HTTPS. Point the server domain's
DNS records at the proxy; a DNS alias by itself does not redirect WebFinger.
If your file already has an [http] section, edit that one.
Choose both names before creating accounts. Other servers store your actor
URLs, and changing the domain later does not update those copies. For a
single-domain instance, use the same name for both settings and skip the
WebFinger redirect below. Older configurations using domain
still work.
Put a proxy in front
littleFedi listens on loopback and does not terminate TLS itself. Configuration
examples for nginx and Caddy ship in the packaging/ directory,
along with the littleMesh gateway files.
Caddy
With the domains above, the Caddyfile is small:
social.example.com {
reverse_proxy 127.0.0.1:8080
}
example.com {
redir /.well-known/webfinger https://social.example.com{uri} 302
}
Caddy obtains the certificates and handles streaming connections. If
example.com already has a site block, add only the
redir line to it. Keep the rest of your website configuration.
caddy validate --config /etc/caddy/Caddyfile
nginx
This goes in the http context, usually through an included site
file. Install valid certificates for both names first and arrange renewal.
Replace the paths below with yours. Define the map only once.
The acme-challenge location is for certbot's --webroot
mode; point it at the directory you pass to certbot, or drop it if you renew
some other way.
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
listen [::]:80;
server_name example.com social.example.com;
location /.well-known/acme-challenge/ {
root /var/www/acme;
}
location / {
return 308 https://$host$request_uri;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name social.example.com;
ssl_certificate /etc/letsencrypt/live/social.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/social.example.com/privkey.pem;
client_max_body_size 41m;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 1h;
proxy_buffering off;
}
}
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
location = /.well-known/webfinger {
return 302 https://social.example.com$request_uri;
}
location / {
return 404;
}
}
The last server block is for a domain with no website yet. If yours already
hosts one, add only the WebFinger location to its HTTPS server
block and leave the other locations alone. The 41 MiB proxy limit leaves room
for the form around a 40 MiB upload. Buffering is off so streaming events reach
the client as they arrive.
nginx -t
Validate the configuration before reloading your proxy. The longer example in
packaging/nginx-littlefedi.conf also sets separate rate limits for
login, federation and ordinary requests.
Check the connection
- Point A and AAAA records at the proxy and test both address families. If IPv6 is not routed and firewalled properly, do not publish an AAAA record.
- Set
http.proxy_urito the exact public HTTPS origin. - Set
http.trusted_proxiesto the proxy's address. In the usual single-host topology that is loopback and nothing else. Never put broad internet ranges in there. If the proxy is on another machine, use a private listener address and trust only that proxy. An untrusted local proxy makes visitors share one rate limit. - Permit inbound TCP 80 and 443 only. Keep port 8080, the metrics endpoint, the profiler, the database and SSH off the public network.
- Use an automated ACME client and alert 21 days before expiry.
Then check the three endpoints that tell you it worked:
curl --fail http://127.0.0.1:8080/health
curl --fail http://127.0.0.1:8080/readyz
curl --fail https://social.example.com/.well-known/nodeinfo
For split domains, check discovery with an account you have actually created:
curl --fail -i 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com'
curl --fail -L 'https://example.com/.well-known/webfinger?resource=acct:alice@example.com'
The first request should redirect to social.example.com without
losing the resource parameter. The second should return JSON with
acct:alice@example.com as its subject and
https://social.example.com/users/alice as the actor URL. Then try a
follow in both directions from another instance.
This setup is also described in my post on reverse proxies and split domains.
Fill in the instance profile
init offers to write the one-line and paragraph descriptions, the
moderation contact and the server rules. That is what /about and
every Mastodon client show about your server, and an empty profile makes the server look abandoned.
You can also do it later from the admin console, without a restart. The config file is the seed and the console is the override; see the instance profile for how the two interact, including the one field where they do not.
Email and SMTP TLS
SMTP defaults to STARTTLS on port 587. Use implicit_tls = true for
SMTPS, normally on port 465. Certificate-chain and hostname verification stay
enabled in both modes, and there is an administrator SMTP test in the console
that only ever sends to your own address.
A private relay with a self-signed certificate can opt out with
insecure_skip_verify = true or
LITTLEFEDI_SMTP_INSECURE_SKIP_VERIFY=true. This accepts
any certificate on that connection, not only the one you had in mind.
Use it on a trusted network, log the fact, and replace it with a valid
certificate. A startup warning is logged for as long as it is on.
Small machines
On a Raspberry Pi Zero W or anything of that size, start here:
low_power = true
[media]
cache_remote = "off"
The preset selects one database connection and one queue worker, a bounded memory cache, one image decoder, a 13 million pixel bound on decoded images (enough for a 4032 by 3024 phone photo), a 1600 pixel cap on stored uploads, cheaper thumbnail resampling, and no dynamic gzip.
Measure on the actual device before promising anything.
Other build variants
make build-postgres
make build-s3
make build-postgres-s3
make build-blog
Build tags keep optional dependencies out of the default binary:
postgres adds PostgreSQL storage and cross-process streaming,
s3 adds S3-compatible media storage and migration, and
blog adds static blog generation. If you
do not ask for them, they are not linked in.
These targets produce littlefedi-postgres,
littlefedi-s3, littlefedi-postgres-s3 and
littlefedi-blog. Run the one you built. To include blogs with a
storage variant, use make build-postgres-s3 TAGS=blog, for example.
The downloaded binaries already have the blog tag.
Your first post
printf 'Hello from a new instance.\n' | \
./littlefedi --config littlefedi.toml post
./littlefedi --config littlefedi.toml post --username alice \
--markdown --visibility private post.md
Then follow someone remote from the web interface, wait for them to appear in the home timeline, and check the queue drained. If that works, federation works.
Adding a federation relay
A new instance can have a rather empty federated timeline. A LitePub relay brings in public posts from other participating servers, and your public posts can reach them too. It is optional. On a small machine I would start without one and add it once I know how much traffic the instance can comfortably handle.
Ask the relay operator for its HTTPS ActivityPub actor URL. Use that exact URL, rather than its inbox or the address of its website. The address below is a placeholder:
./littlefedi --config littlefedi.toml admin relay add --actor https://relay.example.net/actor
./littlefedi --config littlefedi.toml admin relay list
./littlefedi --config littlefedi.toml admin relay status --actor https://relay.example.net/actor
Run these as the service account, with the same environment as the running server. Adding the relay saves it and queues the follow request. Leave the server and its queue workers running; the command itself does not deliver it.
pending: waiting for the relay to accept the follow.awaiting-follow-back: it accepted, but has not followed the instance back yet.active: both sides have accepted.rejected: the relay refused the request. Check its membership policy before trying again.disabled: the saved relay has been switched off.error: the saved actor or follow records are incomplete. Check the logs and actor URL.
You can switch it off, enable it again, or remove the saved entry:
./littlefedi --config littlefedi.toml admin relay disable --actor https://relay.example.net/actor
./littlefedi --config littlefedi.toml admin relay enable --actor https://relay.example.net/actor
./littlefedi --config littlefedi.toml admin relay remove --actor https://relay.example.net/actor
Watch queue depth, disk use and the federated timeline after joining. Federation policy still applies; in allowlist mode, review the domains you intend to receive as well as the relay. A federation relay exchanges posts. The littleMesh lighthouse carries network connections for nodes behind NAT; it is a separate service.
Before you invite anyone
- Keep registrations closed until somebody is willing to moderate.
- Enroll TOTP for the administrator, store the recovery codes offline, then
turn on
require_admin_mfaand confirm you can still get in. - Publish rules, a moderation contact and terms. The policy checklist lists what they should cover.
- Take a backup and restore it somewhere else. Until you have restored one, you don't know your backups work.
- Read the deployment guide for the service account, the file modes, the descriptor limit and the alerts.