This is the Setup section of the LinkJar PDS documentation, as Markdown.
# Host your own PDS
> Install, migrate, and operate your AT Protocol server.
[Source](https://pds.linkjar.io/start/overview/)
LinkJar PDS is an AT Protocol Personal Data Server written in Rust. Host your accounts, records, and media, and connect them to the wider network.
This guide takes you from a Linux host to your first account, then covers the work of keeping the server running.
## Choose your starting point
[Set up a new server](https://pds.linkjar.io/start/requirements/) Prepare a host and domain, then choose Nix, a native binary, or Docker Compose.
[Move from the reference PDS](https://pds.linkjar.io/operate/migrate-from-reference/) Check your existing data, plan the switch, and review rollback limits.
## Choose how to run it
[Native Linux](https://pds.linkjar.io/start/native/#linux-binary-with-systemd) A portable AMD64 or ARM64 binary, managed by systemd.
[NixOS](https://pds.linkjar.io/start/native/#nixos-service) A pinned package, a service module, and declarative configuration.
[Docker Compose](https://pds.linkjar.io/start/install/) A container deployment with a pinned image and persistent volumes.
[Understand the pieces](https://pds.linkjar.io/reference/binaries/) The PDS, console, and MCP binaries: what each does and which ports it uses.
## Get a server running
Choose [Nix, a native binary](https://pds.linkjar.io/start/native/), or [Docker Compose](https://pds.linkjar.io/start/install/). All three run the same server and use the same data layout. The examples use SQLite and local blobs, with Caddy handling public HTTPS.
1. **[Prepare the host](https://pds.linkjar.io/start/requirements/)**
Check your chosen runtime, storage, network access, and domain.
2. **[Set up DNS](https://pds.linkjar.io/start/dns/)**
Point the server name and account handles at your host.
3. **Choose a build and install**
Read [builds and downloads](https://pds.linkjar.io/start/builds/), then install with [Nix or a binary](https://pds.linkjar.io/start/native/) or [Docker Compose](https://pds.linkjar.io/start/install/). Pin the build, generate secrets, and check configuration before startup.
4. **[Verify the setup](https://pds.linkjar.io/start/verify/)**
Check HTTPS, server metadata, and health from outside the host.
5. **[Create your first account](https://pds.linkjar.io/start/first-account/)**
Make an invite, create an account, and sign in with a client.
## Connect your tools
[Connect an AI client](https://pds.linkjar.io/connect/mcp/) Give an MCP client access to your account through sign-in and consent.
[Open the operations console](https://pds.linkjar.io/connect/console/) Inspect accounts, sessions, and audit events through a private connection.
For help with installation, [bring these guides to your AI assistant](https://pds.linkjar.io/connect/ai-guidance/). The manual steps remain available for every deployment method.
## Keep it running
[Back up and restore](https://pds.linkjar.io/operate/backup/) Keep account data, blobs, and the secrets needed to recover them.
[Update the server](https://pds.linkjar.io/operate/update/) Update a pinned binary, NixOS package, or image and review rollback limits.
[Monitor the service](https://pds.linkjar.io/operate/monitoring/) Read logs, check health, and collect operational metrics.
[Find a setting](https://pds.linkjar.io/configure/environment/) Environment variables, defaults, and request resource limits.
> **Before hosting other people's data**
>
> Set up [email for account recovery](https://pds.linkjar.io/configure/email/), keep a tested [backup](https://pds.linkjar.io/operate/backup/), and review the [authentication limits when rolling back](https://pds.linkjar.io/operate/update/#roll-back). A database that an older server can read does not guarantee the same credential-revocation protection.
## Understand the system
The [architecture guide](https://pds.linkjar.io/reference/architecture/) explains the server’s parts and data files. For larger deployments, start with [Postgres](https://pds.linkjar.io/scale/postgres/) or the [entryway and member model](https://pds.linkjar.io/scale/entryway/). If a check fails, use the [troubleshooting guide](https://pds.linkjar.io/reference/troubleshooting/).
These pages describe LinkJar PDS. The upstream [AT Protocol documentation](https://atproto.com/) explains the protocol, and its [self-hosting guide](https://atproto.com/guides/self-hosting) links to the reference server. LinkJar’s implementation and deployment instructions are maintained in the [source repository](https://github.com/linkjar/pds).
# What you need
> Prepare a Linux host, choose Docker or a native installation, and configure the domain and network access for LinkJar PDS.
[Source](https://pds.linkjar.io/start/requirements/)
A PDS holds the accounts of a few people and talks to the rest of the network for them. One small host is enough.
## A host
| | |
| ---------------- | ------------------------------------------------------------------------------------------------ |
| Operating system | Linux, on `amd64` or `arm64` |
| Software | Docker Engine with Compose, or [Nix / a native executable](https://pds.linkjar.io/start/native/) |
| Memory | 1 GiB is plenty. The server starts in a few MiB; Caddy takes a few tens |
| Disk | 20 GB to start. Records live in SQLite files, images and videos as files beside them |
| Network | A public IP address, with ports 80 and 443 open to the internet |
If you choose the Compose deployment, check Docker on the host:
```bash
docker compose version
```
It prints `Docker Compose version v2…`. The older `docker-compose` with a hyphen, version 1, does not read the Compose file of this guide.
## A domain name
The server needs a name of its own, such as `pds.example.com`, at a DNS provider where you can add a wildcard record. Each account gets a handle under that name, `alice.pds.example.com`, and each handle is a name the server answers for. [Point DNS at the host](https://pds.linkjar.io/start/dns/) has the records.
Keep the PDS on a domain of its own, not on a subdomain of a site that serves a web app. The server’s authorization pages and the blobs it serves should not share a parent domain with an app’s cookies.
## HTTPS and CA certificates
The Compose deployment includes Caddy. A native installation needs its own TLS proxy; the [native guide](https://pds.linkjar.io/start/native/#public-https) includes a Caddy example. Caddy uses an operator email for certificate notices. Native hosts also need a CA certificate bundle for the PDS’s outbound HTTPS requests.
## Optional: an SMTP account
The server sends mail to confirm an address and to reset a password. Without SMTP it sends none, which is fine for a server of one. [Email](https://pds.linkjar.io/configure/email/) has the setup.
## Placeholders in this guide
| Placeholder | Replace with |
| ---------------------- | ---------------------------------- |
| `pds.example.com` | the name of your server |
| `203.0.113.10` | the public IP address of your host |
| `operator@example.com` | your email address |
| `alice` | the first account’s handle |
Run commands on the host unless a page says otherwise. Docker commands run from the Compose directory. Native service commands use the service user and runtime configuration, as explained in [the CLI guide](https://pds.linkjar.io/operate/cli/).
# Builds and downloads
> Choose a native package, download a checked Linux binary, or build LinkJar PDS with Nix or Cargo.
[Source](https://pds.linkjar.io/start/builds/)
`linkjar-pds` is the Rust server executable. Choose a build for your host, then follow [native installation](https://pds.linkjar.io/start/native/) for configuration and startup.
| Build | Platforms | Needs on the destination host |
| -------------------------------------------------------- | ------------------------------------------------- | --------------------------------------------------- |
| Nix package | `x86_64-linux`, `aarch64-linux`, `aarch64-darwin` | Nix and the package’s store closure |
| Portable static executable | `x86_64-linux`, `aarch64-linux` | Linux and a CA certificate bundle; no Nix or Docker |
| Cargo release build | The build host’s supported Rust target | Its runtime libraries and CA certificates |
| [Container image](https://pds.linkjar.io/start/install/) | Linux AMD64 and ARM64 | Docker Engine and Compose |
The Linux packages are built on their own architectures. Apple Silicon supports the normal Nix package for local use. There is no Intel macOS package or portable macOS archive. The packages contain the PDS server; console and MCP sidecars are separate builds. See [binaries and ports](https://pds.linkjar.io/reference/binaries/) for their build commands, runtime files, and network connections.
## Download a portable Linux build
Open the [Native packages workflow](https://github.com/linkjar/pds/actions/workflows/nix.yml). Choose a successful run and check its source commit before downloading. Use a reviewed `main` build for an installation. Pull request artifacts are review builds and can contain unmerged changes.
The artifacts are `linkjar-pds-x86_64-linux` and `linkjar-pds-aarch64-linux`. Each contains a `.tar.gz` archive and its `.tar.gz.sha256` checksum file. GitHub keeps them for 14 days. They require GitHub access to download and are not permanent GitHub Release assets. Build from a pinned revision if an artifact has expired.
With the GitHub CLI, list successful main builds:
```bash
gh run list --repo linkjar/pds --workflow nix.yml --branch main --status success
```
Set the run ID you reviewed, then inspect its commit and result:
```bash
PDS_RUN_ID=REPLACE_WITH_REVIEWED_RUN_ID
gh run view "$PDS_RUN_ID" --repo linkjar/pds --json headSha,event,status,conclusion,url
```
Select the host architecture:
```bash
case "$(uname -m)" in
x86_64) PDS_SYSTEM=x86_64-linux ;;
aarch64|arm64) PDS_SYSTEM=aarch64-linux ;;
*) echo 'No portable build for this architecture' >&2; exit 1 ;;
esac
```
On Linux, download into a new, empty directory:
```bash
gh run download "$PDS_RUN_ID" --repo linkjar/pds \
--name "linkjar-pds-$PDS_SYSTEM" --dir native-download
```
Verify the archive before extracting it:
```bash
(cd native-download && sha256sum --check "linkjar-pds-$PDS_SYSTEM.tar.gz.sha256") &&
mkdir native-unpack &&
tar -xzf "native-download/linkjar-pds-$PDS_SYSTEM.tar.gz" -C native-unpack &&
./native-unpack/linkjar-pds version
```
A checksum detects damaged or changed downloads. Also check the run’s repository and source commit; the checksum alone does not establish who built it. The CLI version is the Cargo package version and can be shared by several commits. Keep the full commit and archive checksum in your deployment record.
Install the reviewed executable in a directory named after its commit:
```bash
PDS_REV=$(gh run view "$PDS_RUN_ID" --repo linkjar/pds --json headSha --jq '.headSha') &&
sudo install -d -m 0755 "/opt/linkjar-pds/$PDS_REV" &&
sudo install -m 0755 native-unpack/linkjar-pds "/opt/linkjar-pds/$PDS_REV/linkjar-pds" &&
sudo install -m 0644 native-unpack/LICENSE "/opt/linkjar-pds/$PDS_REV/LICENSE" &&
sudo ln -sfn "/opt/linkjar-pds/$PDS_REV/linkjar-pds" /usr/local/bin/linkjar-pds
```
This symlink is for a new installation. For an existing server, follow [the update procedure](https://pds.linkjar.io/operate/update/#native-binary) before changing it. Keep CA certificates installed for outbound HTTPS. Set `SSL_CERT_FILE` in the service environment if the bundle is in a nonstandard location.
## Build with Nix
Use Nix with the `nix-command` and `flakes` experimental features enabled. Check out the reviewed source commit and run these commands from the repository root. Keep `flake.lock` and `Cargo.lock` unchanged for that build.
```bash
nix build .#linkjar-pds
result/bin/linkjar-pds version
nix run . -- version
```
The normal package uses libraries in the Nix store. Keep the `result` symlink as a garbage-collection root, or install the package through your host’s Nix configuration. Copying just this executable to another host is insufficient. Use the NixOS module for a persistent NixOS installation.
On a Linux builder, create a portable static musl executable instead:
```bash
nix build .#linkjar-pds-static --out-link result-static
result-static/bin/linkjar-pds version
```
Copy `result-static/bin/linkjar-pds` to a Linux host with the same CPU architecture. The static executable has no dynamic loader or shared-library dependency. Its throughput has not been benchmarked against the normal package; compare your workload before changing a production build.
`flake.lock` pins Nixpkgs and rust-overlay. The overlay resolves the toolchain in `rust-toolchain.toml` against those locked inputs. `Cargo.lock` pins the Rust dependencies. A normal build does not update either lockfile.
## Build with Cargo
Install the toolchain selected by `rust-toolchain.toml`, a C compiler, CMake, and pkg-config. Build only the server:
```bash
cargo build --release --locked --package linkjar-pds --bin linkjar-pds
target/release/linkjar-pds version
```
The output is `target/release/linkjar-pds`. It targets the build host and can depend on its shared libraries. Node, pnpm, the console assets, and the simulation are not required to compile this server target.
For a development shell with the workspace tools:
```bash
nix develop
```
## What CI checks
The **Native packages** workflow evaluates all supported platforms, then builds the normal and static packages on both Linux architectures. It checks the copied static executable for dynamic dependencies and tests configuration, startup, HTTP health, graceful shutdown, and database verification on temporary data. An x86-64 NixOS VM test checks the service user, state permissions, persistence, restart, and firewall isolation.
The separate **Rust** workflow runs the workspace tests and Rust checks. The **Site** workflow validates documentation and saves the static `pds-docs` artifact. These workflows do not deploy the server or documentation. The docs are hosted on Cloudflare Workers at [pds.linkjar.io](https://pds.linkjar.io/); GitHub Pages is not used.
Next: [configure and run the native server](https://pds.linkjar.io/start/native/).
# Binaries and ports
> The PDS, operations console, and MCP server, their build targets, and the network connections between them.
[Source](https://pds.linkjar.io/reference/binaries/)
Start with `linkjar-pds`. Add the console for operators or the MCP server for AI clients when you need them. Each is a separate Rust executable.
## What runs where
| Executable | Purpose | Distribution |
| --------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------- |
| `linkjar-pds` | Hosts accounts, repositories, blobs, OAuth, and the optional private operations API | Nix package, portable Linux archive, Cargo, or Docker |
| `linkjar-pds-console` | Gives operators a browser interface to the private operations API | Cargo with its asset bundle, or `Dockerfile.console` |
| `linkjar-pds-mcp` | Connects an AI client to an account through MCP and OAuth | Cargo, or `Dockerfile.mcp` |
The Nix package and portable archives currently include **only `linkjar-pds`**. There are no published native sidecar archives or sidecar NixOS modules in this repository. The `pds-sidecar` crate is a shared library, not another executable.
The console and MCP server use authenticated APIs. They do not open the PDS database or need its admin password or PLC rotation key. The MCP server has its own OAuth client key.
## Network map
| Service | Native address or port | Who connects |
| ------------------ | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| TLS proxy | Public `443`; usually `80` for HTTPS redirects and certificate setup | Apps, browsers, relays, and remote AI clients |
| PDS HTTP | `2583`, on all interfaces; `PDS_PORT` changes it | The proxy and trusted sidecars; block public access with the host firewall |
| PDS operations API | Disabled unless `PDS_OPS_ADDRESS` is set; use `127.0.0.1:2584` on one host | The console and authorized operator tools |
| Operations console | `127.0.0.1:2585`; set with `CONSOLE_ADDRESS` | Your browser through an SSH tunnel |
| MCP HTTP | `127.0.0.1:2586`; set with `MCP_ADDRESS` | A TLS proxy for the MCP hostname |
Port `2584` is a convention in the examples, not an automatically enabled listener. Keep it private. The console’s browser URL must be an HTTP loopback address; a public console hostname is not supported.
The PDS image sets its internal HTTP port to `3000`. Compose sidecars use `http://pds:3000`; sidecars beside a native installation use `http://127.0.0.1:2583`. Inside a container, `127.0.0.1` is that container, not the host or a sibling service. Use the [Compose examples](https://pds.linkjar.io/scale/sidecars/) for that topology.
## Platforms and runtime files
| Build | Supported package targets | Files to retain |
| ------------------------- | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| Normal PDS Nix package | Linux AMD64, Linux ARM64, Apple Silicon macOS | The Nix store closure |
| Portable PDS archive | Linux AMD64 and Linux ARM64 | The executable, license, deployment commit, and checksum |
| Sidecars built with Cargo | Build for the intended host; no portable sidecar release matrix yet | Executable and required runtime libraries; the console also needs its `assets/` directory |
Native services need CA certificates for outbound HTTPS. The MCP and console keep sessions in memory, so restarting either requires its users to sign in again. The PDS data directory must persist independently of executable updates.
## Build the sidecars
Use a reviewed checkout and the toolchain in `rust-toolchain.toml`. The [build prerequisites](https://pds.linkjar.io/start/builds/#build-with-cargo) apply here too.
**Build the MCP server**
```bash
cargo build --release --locked --package pds-mcp --bin linkjar-pds-mcp
```
**Build and bundle the operations console**
```bash
cargo build --release --locked --package pds-console --bin linkjar-pds-console &&
target/release/linkjar-pds-console bundle-assets target/release/assets
```
Bundle the console assets **on the build machine**, before copying the executable elsewhere. Copy `target/release/assets/` alongside the executable as `assets/`. Without that bundle, the console attempts to build its assets at runtime using files from the source tree.
The console build downloads a pinned, checksum-verified Tailwind CLI. To use an existing compatible executable, set `TAILWIND_CLI` before building.
## Choose the next guide
* [Install the native PDS](https://pds.linkjar.io/start/native/) or [use Docker Compose](https://pds.linkjar.io/start/install/).
* [Connect an AI client with MCP](https://pds.linkjar.io/connect/mcp/).
* [Set up the operations console](https://pds.linkjar.io/connect/console/).
* [Use the PDS operator commands](https://pds.linkjar.io/operate/cli/).
# Point DNS at the host
> The two records a PDS needs, the ports to open, and how to check both before you install.
[Source](https://pds.linkjar.io/start/dns/)
Add two records at your DNS provider. Both point at the host.
| Name | Type | Value |
| ------------------- | ---- | -------------- |
| `pds.example.com` | `A` | `203.0.113.10` |
| `*.pds.example.com` | `A` | `203.0.113.10` |
Add `AAAA` records with the same names when the host has a public IPv6 address.
The wildcard matters. An account’s handle, `alice.pds.example.com`, is a host name of its own: apps resolve it to find the account’s DID, and Caddy fetches a certificate for it the first time a client asks. Without the wildcard, handles do not resolve.
> **DNS only, no proxy**
>
> If your DNS provider can proxy traffic through its own edge, leave the proxy off for both records. Caddy needs to answer the certificate challenge itself, and the firehose is a WebSocket that stays open for hours.
## Check the records
Wait until both answers are right. A DNS change takes a few minutes to spread.
```bash
dig +short pds.example.com
```
```bash
dig +short anything.pds.example.com
```
Each prints `203.0.113.10`.
## Open the ports
Open ports 80 and 443 in the host’s firewall and in your provider’s firewall, if it has one. Port 80 serves the certificate challenge and the redirect to HTTPS; 443 serves everything else. The Compose server listens on port `3000` inside its network. Native examples use port `2583`, blocked from public access by the host firewall. Send public traffic through the TLS proxy; keep metrics and operations listeners private.
Next: [choose a build](https://pds.linkjar.io/start/builds/), then install with [Nix or a binary](https://pds.linkjar.io/start/native/) or [Docker Compose](https://pds.linkjar.io/start/install/).
# Install with Nix or a binary
> Configure a native LinkJar PDS, run it with systemd or NixOS, and put HTTPS in front of it without Docker.
[Source](https://pds.linkjar.io/start/native/)
The server runs as one Rust executable. First [download or build it](https://pds.linkjar.io/start/builds/). For Linux without Nix, use the portable static executable. On NixOS, use the module below. A foreground example is included for local checks.
You need a domain, a writable data directory, a blob store, CA certificates, and a TLS proxy for public HTTPS. The HTTP listener binds all interfaces. Keep port `2583` behind the host’s firewall and allow public traffic through your TLS proxy. Never enable `PDS_DEV_MODE` on a public host.
## Configure the server
For a new installation, generate a JWT secret and admin password separately:
```bash
openssl rand --hex 32
openssl rand --hex 32
```
Generate a secp256k1 PLC rotation key on Linux:
```bash
openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32
```
Keep these values in a secret manager or a restricted file. Reuse the original secrets when moving an existing server. The rotation key controls the accounts’ DIDs; replacing it is not an installation reset.
Create `/etc/linkjar-pds/pds.env`, owned by root with mode `0600`, under a root-owned directory. Create the directory before editing the file:
```bash
sudo install -d -m 0700 -o root -g root /etc/linkjar-pds
sudoedit /etc/linkjar-pds/pds.env
sudo chmod 0600 /etc/linkjar-pds/pds.env
```
Put one literal `NAME=value` assignment on each line. Replace the three secret placeholders:
**/etc/linkjar-pds/pds.env**
```dotenv
PDS_HOSTNAME=pds.example.com
PDS_JWT_SECRET=REPLACE_WITH_JWT_SECRET
PDS_ADMIN_PASSWORD=REPLACE_WITH_ADMIN_PASSWORD
PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=REPLACE_WITH_ROTATION_KEY
PDS_BLOBSTORE_DISK_LOCATION=/var/lib/linkjar-pds/blocks
PDS_INVITE_REQUIRED=true
PDS_BSKY_APP_VIEW_URL=https://api.bsky.app
PDS_BSKY_APP_VIEW_DID=did:web:api.bsky.app
PDS_REPORT_SERVICE_URL=https://mod.bsky.app
PDS_REPORT_SERVICE_DID=did:plc:ar7c4by46qjdydhdevvrndac
PDS_CRAWLERS=https://bsky.network
```
Systemd reads this file; the binary does not load `.env` files itself. Keep all settings needed by operator commands in this runtime file. The examples below set `PDS_DATA_DIRECTORY` and `PDS_PORT` in the service definition. Leave them out of the file so they cannot override those settings.
For [S3 storage](https://pds.linkjar.io/configure/blob-storage/), remove `PDS_BLOBSTORE_DISK_LOCATION` and add the S3 settings and credentials. Set up [email](https://pds.linkjar.io/configure/email/) before inviting other people. [Environment variables](https://pds.linkjar.io/configure/environment/) lists the remaining options.
## NixOS service
Add a pinned input to your host’s flake. Replace `` with the full commit you intend to run:
```nix
inputs.linkjar-pds.url = "github:linkjar/pds/";
```
Add `inputs.linkjar-pds.nixosModules.default` to your host’s `modules` list. In a host module, enable the service and put the same package on the operator’s command path:
```nix
{ inputs, pkgs, ... }:
{
services.linkjar-pds = {
enable = true;
environmentFile = "/etc/linkjar-pds/pds.env";
};
environment.systemPackages = [
inputs.linkjar-pds.packages.${pkgs.stdenv.hostPlatform.system}.linkjar-pds
];
}
```
This example assumes your flake passes `inputs` through `specialArgs` to the host modules. You can instead reference the input in the outer flake expression.
Provision the runtime file before activating the service. Your existing secret manager can supply it at another runtime path, such as `/run/secrets/linkjar-pds.env`. Use a quoted string for `environmentFile`; never put secrets in a Nix expression, `builtins.toFile`, or a Nix path copied into the store.
The module creates the `linkjar-pds` user and group and mode `0700` state at `/var/lib/linkjar-pds`. It checks configuration before startup, restarts after failure, and restricts filesystem access. It supplies CA certificates and keeps the HTTP port closed in the firewall by default. Set `services.linkjar-pds.port` if you need a port other than `2583`. Configure your TLS proxy separately.
Activate the reviewed host configuration with your usual `nixos-rebuild` procedure. Then check the service:
```bash
sudo systemctl status linkjar-pds
sudo journalctl -u linkjar-pds -n 50 --no-pager
curl --fail http://127.0.0.1:2583/xrpc/_health
```
The service protects `/home` and `/root`. Keep additional key files in an accessible runtime secret directory. Use `services.linkjar-pds.environment` only for public settings; [operator commands](https://pds.linkjar.io/operate/cli/#native-services) need those settings too.
## Linux binary with systemd
This example uses the executable installed at `/usr/local/bin/linkjar-pds` by the [download guide](https://pds.linkjar.io/start/builds/#download-a-portable-linux-build). Keep the host’s CA certificate package installed.
Create a dedicated account and data directory. On Debian or Ubuntu:
```bash
sudo useradd --system --user-group --home-dir /var/lib/linkjar-pds --shell /usr/sbin/nologin linkjar-pds
sudo install -d -m 0700 -o linkjar-pds -g linkjar-pds /var/lib/linkjar-pds
```
Create the account only once. If you use another distribution, use its system account command. Save this unit as `/etc/systemd/system/linkjar-pds.service`:
**/etc/systemd/system/linkjar-pds.service**
```ini
[Unit]
Description=LinkJar AT Protocol Personal Data Server
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=linkjar-pds
Group=linkjar-pds
WorkingDirectory=/var/lib/linkjar-pds
EnvironmentFile=/etc/linkjar-pds/pds.env
Environment=PDS_DATA_DIRECTORY=/var/lib/linkjar-pds
Environment=PDS_PORT=2583
ExecStartPre=/usr/local/bin/linkjar-pds check-config
ExecStart=/usr/local/bin/linkjar-pds serve
Restart=on-failure
RestartSec=5
TimeoutStopSec=30
StateDirectory=linkjar-pds
StateDirectoryMode=0700
UMask=0077
NoNewPrivileges=true
PrivateTmp=true
PrivateDevices=true
ProtectSystem=strict
ProtectHome=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectControlGroups=true
RestrictSUIDSGID=true
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
CapabilityBoundingSet=
[Install]
WantedBy=multi-user.target
```
After saving the runtime environment file and firewall rules, start it:
```bash
sudo systemctl daemon-reload
sudo systemctl enable --now linkjar-pds
sudo systemctl status linkjar-pds
sudo journalctl -u linkjar-pds -n 50 --no-pager
curl --fail http://127.0.0.1:2583/xrpc/_health
```
## Public HTTPS
Point the TLS proxy at `127.0.0.1:2583`. It must handle the server hostname, account handle names, and long-lived WebSocket connections for the firehose. For a native Caddy installation, adapt the repository’s Caddyfile:
**Caddyfile**
```caddyfile
{
email operator@example.com
on_demand_tls {
ask http://127.0.0.1:2583/tls-check
}
}
pds.example.com, *.pds.example.com {
tls {
on_demand
}
reverse_proxy 127.0.0.1:2583
}
```
Run Caddy as its own service with persistent certificate storage. The DNS and ports in [the DNS guide](https://pds.linkjar.io/start/dns/) apply to this setup too. The `/tls-check` guard limits certificate requests to the server and active account handles. For a different proxy, configure equivalent hostname, TLS, and WebSocket support.
## Foreground checks
On a private development host, run the binary as your own user with disposable state. Set the required settings in that shell first:
```bash
export PDS_HOSTNAME=pds.example.com
export PDS_DATA_DIRECTORY="$PWD/native-data"
export PDS_BLOBSTORE_DISK_LOCATION="$PWD/native-data/blocks"
export PDS_JWT_SECRET=REPLACE_WITH_JWT_SECRET
export PDS_ADMIN_PASSWORD=REPLACE_WITH_ADMIN_PASSWORD
linkjar-pds check-config
linkjar-pds serve
```
Use the executable path from your build if it is not installed on `PATH`. Stop it with Ctrl-C. This example does not configure public TLS or a rotation key for creating accounts. Never point it at a live production data directory.
## Move from Docker
Take a tested [backup](https://pds.linkjar.io/operate/backup/), stop the old server, and preserve the complete data directory and every secret. Review the [authentication limits on rollback](https://pds.linkjar.io/operate/update/#roll-back).
Copy the stopped data to `/var/lib/linkjar-pds`, then assign it to `linkjar-pds:linkjar-pds`. Change container paths such as `/app/data` to host paths in the environment. Preserve external database and blob-store settings. Run [native verification](https://pds.linkjar.io/operate/cli/#native-services) before starting. Only one server may use the data, including copies on different hosts.
Next: [verify the public setup](https://pds.linkjar.io/start/verify/), then [create an account](https://pds.linkjar.io/start/first-account/). Use the operator guides for [updates](https://pds.linkjar.io/operate/update/), [backups](https://pds.linkjar.io/operate/backup/), and [monitoring](https://pds.linkjar.io/operate/monitoring/).
# Install with Docker Compose
> Get the Compose file, fill in the secrets, start the server and Caddy.
[Source](https://pds.linkjar.io/start/install/)
For an installation without Docker, use the [Nix package, NixOS service, or native binary](https://pds.linkjar.io/start/native/).
The deployment is four files from the repository: a Compose file with the server and Caddy, a Caddyfile, and two example environment files.
The Compose template pins `caddy:2.11.7-alpine` by image digest. Updating the repository does not update an already running edge; apply the changed template during the deployment’s normal update process.
* deploy/compose/
* compose.yml the server and Caddy
* Caddyfile certificates on demand, for the server and each handle
* example.env for Compose: the image, the name, your email
* example.pds.env for the server: secrets and settings
1. Get the files onto the host.
```bash
git clone --depth 1 https://github.com/linkjar/pds.git
```
```bash
cd pds/deploy/compose
```
2. Choose the image.
* Published image
Every push to `main` publishes `ghcr.io/linkjar/pds-server` for `amd64` and `arm64`. Resolve the `main` tag to a digest, and pin the digest: a digest names one build, where a tag moves.
```bash
docker buildx imagetools inspect ghcr.io/linkjar/pds-server:main --format '{{.Manifest.Digest}}'
```
It prints `sha256:…`. The image is `ghcr.io/linkjar/pds-server@sha256:…`.
* Build from source
The repository’s `Dockerfile` builds the server with the pinned toolchain. Run this from the repository root, on the host or on a workstation with the same architecture. The first build takes a few minutes.
```bash
docker build -t linkjar-pds:local .
```
The image is `linkjar-pds:local`.
3. Write `.env`. Compose reads it; the server does not.
```bash
cp example.env .env
```
Set `PDS_IMAGE` to the image, `PDS_HOSTNAME` to `pds.example.com` and `ACME_EMAIL` to `operator@example.com`.
4. Write `pds.env`, the server’s secrets and settings.
```bash
cp example.pds.env pds.env
```
```bash
chmod 600 pds.env
```
Generate the three secrets and paste each into its line. Keep them. Sessions and the identities of the accounts depend on them, and a lost rotation key is lost control of every account’s DID.
The JWT secret:
```bash
openssl rand --hex 16
```
The admin password:
```bash
openssl rand --hex 16
```
The PLC rotation key:
```bash
openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32
```
The rest of the file holds settings with their usual values: the data directory inside the container, the public PLC directory, the Bluesky AppView and relay, and `PDS_INVITE_REQUIRED=true`. [Environment variables](https://pds.linkjar.io/configure/environment/) explains each.
5. Create the data directory. The server runs as user id 1000 in the image, so the directory belongs to that id.
```bash
sudo install -d -o 1000 -g 1000 data
```
6. Check the configuration without starting the server.
```bash
docker compose run --rm pds linkjar-pds check-config
```
It prints `the configuration is valid`. A missing or malformed variable is named instead; fix it and run the check again.
7. Start the server and Caddy.
```bash
docker compose up -d
```
```bash
docker compose logs pds
```
The server logs JSON lines. A line with `"message":"serving"` and the server’s DID means it is up. Caddy asks for the server’s certificate the first time a client connects.
Next: [check that it works](https://pds.linkjar.io/start/verify/) from outside the host.
# Check that it works
> Four requests from outside the host, each with the answer to expect, and the smoke test that makes them all.
[Source](https://pds.linkjar.io/start/verify/)
Run these from your workstation, not from the host, so that DNS, the firewall and the certificate are all in the path.
## The health route
```bash
curl -s https://pds.example.com/xrpc/_health
```
It answers `{}` with status 200, or `{"version":"…"}` when `PDS_VERSION` is set. A 503 with `"error":"Service Unavailable"` means the account database did not answer: read the logs.
## What the server says about itself
```bash
curl -s https://pds.example.com/xrpc/com.atproto.server.describeServer
```
The answer names the server’s DID, `did:web:pds.example.com`, lists the handle suffix `.pds.example.com` under `availableUserDomains`, and says `"inviteCodeRequired":true`.
## The OAuth metadata
```bash
curl -s https://pds.example.com/.well-known/oauth-authorization-server
```
A JSON document whose `issuer` is `https://pds.example.com`. Apps that sign in with OAuth, the Bluesky app among them, read it first.
## The certificate guard
The supplied Compose and native Caddy configurations ask the server before requesting a certificate for a name, so that only the server’s name and the handles of its accounts get one. Ask the same question:
```bash
curl -s "https://pds.example.com/tls-check?domain=pds.example.com"
```
It answers `{"success":true}`. A name that nobody hosts gets a 404, and a stranger who points a name at your host gets no certificate from it.
## Everything at once
The repository’s smoke test makes the requests above, subscribes to the firehose, and reports one line per check. It needs Node 24 and pnpm on your workstation.
```bash
cd pds/parity && pnpm install
```
```bash
pnpm parity smoke https://pds.example.com
```
Every line starts with `ok`, and the last says how many checks passed.
With `--write` and `PDS_ADMIN_PASSWORD` in the environment, the test also creates an account, posts, uploads an image, makes an app password, and deletes the account again. The account’s DID stays in the PLC directory after the deletion, as every DID does.
```bash
read -s PDS_ADMIN_PASSWORD && export PDS_ADMIN_PASSWORD
```
```bash
pnpm parity smoke https://pds.example.com --write
```
Next: [create the first account](https://pds.linkjar.io/start/first-account/).
# Create the first account
> An invite code, the Bluesky app, the first post, and when the rest of the network sees it.
[Source](https://pds.linkjar.io/start/first-account/)
Sign-up needs an invite code, so that strangers cannot fill the server. The admin password creates codes.
## Create an invite code
On the host, with `PDS_ADMIN_PASSWORD` from your runtime secret file in the environment:
```bash
curl -s -u "admin:$PDS_ADMIN_PASSWORD" -H 'content-type: application/json' -d '{"useCount": 1}' https://pds.example.com/xrpc/com.atproto.server.createInviteCode
```
It answers `{"code":"pds-example-com-xxxxx-xxxxx"}`. A code with a `useCount` of 5 admits five accounts.
## Sign up from the Bluesky app
1. Open the app and choose **Create account**.
2. Under **Hosting provider**, choose **Custom** and enter `https://pds.example.com`.
3. Enter the invite code, an email address, a password and a handle. The handle becomes `alice.pds.example.com`.
4. Post something.
With the supplied Caddy configuration, the first request for `alice.pds.example.com` triggers certificate issuance. It can take a few seconds.
## Or sign up from the terminal
```bash
curl -s -H 'content-type: application/json' -d '{"email":"alice@example.com","handle":"alice.pds.example.com","password":"…","inviteCode":"pds-example-com-xxxxx-xxxxx"}' https://pds.example.com/xrpc/com.atproto.server.createAccount
```
The answer holds the account’s `did`, its `handle` and a session. Sign in with the handle and the password from any app.
## Check the handle
```bash
curl -s https://alice.pds.example.com/.well-known/atproto-did
```
It prints the account’s DID, `did:plc:…`. Apps resolve handles this way.
## When posts reach other people
A post appears in other people’s timelines once the relay at `bsky.network` crawls the host. The server asks it to with the first write after a start, and then at most once in twenty minutes. The relay’s own status shows the connection:
```bash
curl -s "https://bsky.network/xrpc/com.atproto.sync.getHostStatus?hostname=pds.example.com"
```
The answer has `"status":"active"` and a `seq` that moves with each write.
> **Keep invites on**
>
> `PDS_INVITE_REQUIRED=false` opens sign-up to anyone who finds the server. Leave it on and hand out codes; [accounts and invites](https://pds.linkjar.io/operate/accounts/) has the rest of the invite commands.
Next: set up [email](https://pds.linkjar.io/configure/email/) so that confirmation and password-reset mail arrives, and [back up](https://pds.linkjar.io/operate/backup/) the data directory and all configuration and secrets.
# Blob storage
> Images and videos on the disk, or in an S3-compatible bucket.
[Source](https://pds.linkjar.io/configure/blob-storage/)
A blob is an image, a video or any other file an account uploads. By default blobs are files under the data directory. For a host with a small disk, or for a bucket that is backed up and replicated for you, the server can keep them in an S3-compatible store instead.
## On the disk
`PDS_BLOBSTORE_DISK_LOCATION` names the directory, `blocks` under the data directory in both installation examples. The layout is the reference server’s:
| Path | Content |
| ------------------------ | ----------------------------------------------------- |
| `blocks//` | a stored blob |
| `tempt//` | an upload that waits for the record that refers to it |
| `quarantine//` | a blob of a taken-down account or record |
`tempt` and `quarantine` sit beside `blocks`, in the data directory. `PDS_BLOB_UPLOAD_LIMIT` caps one upload, in bytes; the example file sets 100 MiB.
## In an S3-compatible bucket
Set the bucket and remove `PDS_BLOBSTORE_DISK_LOCATION`: the server refuses both at once.
```dotenv
PDS_BLOBSTORE_S3_BUCKET=pds-blobs
PDS_BLOBSTORE_S3_REGION=auto
PDS_BLOBSTORE_S3_ENDPOINT=https://.r2.cloudflarestorage.com
PDS_BLOBSTORE_S3_FORCE_PATH_STYLE=true
PDS_BLOBSTORE_S3_ACCESS_KEY_ID=…
PDS_BLOBSTORE_S3_SECRET_ACCESS_KEY=…
```
The example is Cloudflare R2. MinIO, Backblaze B2, Wasabi and AWS S3 work the same way; AWS needs no endpoint. The rules:
* The region and both halves of the credentials are needed at start. Without a region the server reads `AWS_REGION` or `AWS_DEFAULT_REGION`; without credentials it reads `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` and `AWS_SESSION_TOKEN`. It reads no profile file and no instance role.
* With `FORCE_PATH_STYLE`, or an endpoint that is an IP address, the bucket is the first segment of the path. Otherwise it is a label of the host.
* `PDS_BLOBSTORE_S3_UPLOAD_TIMEOUT_MS` bounds one upload from its first byte to its last, 20 seconds by default.
Objects are named as the reference server names them, `blocks//`, `tmp//` and `quarantine//`, so a bucket the reference server wrote is served as it is. An upload goes to the bucket as the client sends it, in one request below 8 MiB and in parts of 8 MiB above, so the server holds one part in memory and writes nothing to the disk. A request the store refuses with 429 or a 5xx is sent three times at most.
## Check a store
`verify` lists the objects of each account and compares them with the blob index of its repository. It changes nothing in the bucket.
For a native service, run `pds verify` with the [CLI helper](https://pds.linkjar.io/operate/cli/#native-services). For Compose:
```bash
docker compose run --rm pds linkjar-pds verify
```
Moving blobs between the disk and a bucket is a copy with a tool of your choice while the server is stopped; the names are the same on both sides.
# Email
> The mail the server sends, the SMTP URL it needs, and how to test it.
[Source](https://pds.linkjar.io/configure/email/)
The server sends mail for five things: to confirm an email address, to reset a password, to change the address, to delete the account, and to sign a PLC operation. Each mail carries a token, and the flow waits for it.
Without SMTP the server sends nothing. A server of one can go without; before you invite other people, set it up, or nobody can reset a forgotten password.
## Set the SMTP URL
Add these settings to your runtime environment file:
```dotenv
PDS_EMAIL_SMTP_URL=smtps://user:password@smtp.example.com/
PDS_EMAIL_FROM_ADDRESS=pds@example.com
```
The URL names the scheme, the credentials and the host. `smtps://` is TLS on port 465; `smtp://` on port 587 upgrades to TLS. Add a port after the host when the provider uses another one.
> **Percent-encode the password**
>
> A password with a character that means something in a URL, such as `@`, `:`, `/` or `#`, must be percent-encoded. `p@ss` becomes `p%40ss`.
A sender address at the server’s own domain, or at a domain whose SPF and DKIM records name the provider, keeps the mail out of spam folders.
Restart after the change. For NixOS or the native systemd example:
```bash
sudo systemctl restart linkjar-pds
```
For Compose:
```bash
docker compose up -d
```
## Test it
Ask for a password reset for an account whose address you can read:
```bash
curl -s -H 'content-type: application/json' -d '{"email":"alice@example.com"}' https://pds.example.com/xrpc/com.atproto.server.requestPasswordReset
```
The answer is empty with status 200, and the mail arrives within a minute. A mail that gates a flow is sent before the request is answered, so an SMTP failure fails the request, with the reason in the logs:
For a native service, use `sudo journalctl -u linkjar-pds`. For Compose, use `docker compose logs pds`. See [monitoring](https://pds.linkjar.io/operate/monitoring/#logs).
## Mail from a moderation service
A moderation service can send mail to an account through the admin API. It goes out with `PDS_MODERATION_EMAIL_SMTP_URL` and `PDS_MODERATION_EMAIL_ADDRESS` when they are set, and with the server’s own sender otherwise.
# Environment variables
> Every setting a self-hoster is likely to touch, grouped by what it does, with the reference server's defaults.
[Source](https://pds.linkjar.io/configure/environment/)
The server reads configuration from its process environment. Compose loads `pds.env`; native systemd examples load `/etc/linkjar-pds/pds.env`. The binary does not load either file itself. It uses the reference server’s variable names. The tables identify LinkJar defaults and safety restrictions; new settings are at the end.
An invalid value stops the server at start with a message that names the variable. An unknown `PDS_*` variable is a warning. `check-config` runs the same checks without starting anything:
For native services, use the [CLI helper](https://pds.linkjar.io/operate/cli/#native-services):
```bash
pds check-config
```
For Compose:
```bash
docker compose run --rm pds linkjar-pds check-config
```
## The server
| Variable | Meaning | Default |
| ---------------------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------ |
| `PDS_HOSTNAME` | The server’s public name. **Required.** | |
| `PDS_PORT` | The port the public listener binds. | `2583` natively; `3000` in the image |
| `PDS_SERVICE_DID` | The server’s own DID. | `did:web:` and the hostname |
| `PDS_SERVICE_HANDLE_DOMAINS` | The suffixes of hosted handles, each with a leading dot, separated by commas. | `.` and the hostname |
| `PDS_VERSION` | Shown by the health route. | unset |
| `PDS_CONTACT_EMAIL_ADDRESS` | Shown by `describeServer`. | unset |
| `PDS_PRIVACY_POLICY_URL`, `PDS_TERMS_OF_SERVICE_URL` | Linked by `describeServer` and on the sign-up page. | unset |
| `PDS_HOME_URL`, `PDS_SUPPORT_URL` | Links on the OAuth pages. | unset |
| `PDS_DEV_MODE` | Relaxes checks for local development. Never on a public host. | `false` |
## Secrets
| Variable | Meaning |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PDS_JWT_SECRET` | Signs sessions. **Required.** Changing it signs everyone out. |
| `PDS_ADMIN_PASSWORD` | The password of the `admin` user for the admin API and invite codes. **Required.** |
| `PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX` | The key that signs PLC operations for new accounts and handle changes. Without it the server creates no account. Keep it: it is the control of every account’s DID. |
| `PDS_DPOP_SECRET` | Signs the nonces of OAuth proofs. Optional; set it so that nonces survive a restart. |
| `PDS_RECOVERY_DID_KEY` | A `did:key` added to each new account’s DID document as a further rotation key, for recovery with a key kept elsewhere. Optional. |
## Storage
| Variable | Meaning | Default |
| ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| `PDS_DATA_DIRECTORY` | The data directory. Native examples use `/var/lib/linkjar-pds`; Compose mounts it at `/app/data`. | |
| `PDS_BLOBSTORE_DISK_LOCATION` | Where blobs go on disk, usually `blocks` under the data directory. | |
| `PDS_BLOBSTORE_S3_*` | An S3-compatible store in place of the disk. [Blob storage](https://pds.linkjar.io/configure/blob-storage/) has the list. | |
| `PDS_BLOB_UPLOAD_LIMIT` | The largest blob, in bytes. The example file sets 100 MiB. | 5 MiB |
| `PDS_ACTOR_STORE_CACHE_SIZE` | How many accounts’ databases stay open at once. | `100` |
| `PDS_MAX_REPO_IMPORT_SIZE` | The largest repository import body, in bytes. Must be positive; parsing uses additional memory. | 64 MiB (67,108,864 bytes) |
| `PDS_ACCEPTING_REPO_IMPORTS` | Whether accounts may import a repository, as in a migration from another server. | `true` |
| `PDS_SQLITE_DISABLE_WAL_AUTO_CHECKPOINT` | Hands SQLite checkpoints to a backup tool such as Litestream. | `false` |
## Identity
| Variable | Meaning | Default |
| -------------------------------------------------- | --------------------------------------------------------------------------- | ----------------------- |
| `PDS_DID_PLC_URL` | The PLC directory where new DIDs are registered. | `https://plc.directory` |
| `PDS_HANDLE_BACKUP_NAMESERVERS` | Nameservers to ask when the system resolver cannot verify a handle. | unset |
| `PDS_ID_RESOLVER_TIMEOUT` | How long a handle or DID lookup may take, in milliseconds. | `3000` |
| `PDS_DID_CACHE_STALE_TTL`, `PDS_DID_CACHE_MAX_TTL` | How long a cached DID document is served before and after a refresh is due. | 1 hour, 1 day |
## The network
| Variable | Meaning | Usual value |
| -------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- |
| `PDS_BSKY_APP_VIEW_URL`, `PDS_BSKY_APP_VIEW_DID` | The AppView that serves feeds, notifications and preferences for the Bluesky app. Without them the app cannot load its settings. | `https://api.bsky.app`, `did:web:api.bsky.app` |
| `PDS_REPORT_SERVICE_URL`, `PDS_REPORT_SERVICE_DID` | Where `createReport` is forwarded. | `https://mod.bsky.app`, `did:plc:ar7c4by46qjdydhdevvrndac` |
| `PDS_CRAWLERS` | The relays the server asks to crawl it, separated by commas. | `https://bsky.network` |
| `PDS_MAX_SUBSCRIPTION_BUFFER` | How many events a slow firehose subscriber may fall behind before the server drops it. | `500` |
| `PDS_REPO_BACKFILL_LIMIT_MS` | How far back a firehose subscriber may ask for events, in milliseconds. | 3 days |
| `PDS_PROXY_HEADERS_TIMEOUT` | Total upstream proxy deadline, including the response body, in milliseconds. | `10000` |
| `PDS_DISABLE_SSRF_PROTECTION` | Allows private OAuth metadata destinations only with `PDS_DEV_MODE=true`. Production startup rejects it. | `false` |
Untrusted DID, proxy, handle and client-metadata destinations must use public HTTPS on port 443. The connector checks the actual destination addresses, refuses redirects and ignores environment proxies. Configured service URLs, including PLC and AppView, remain trusted and can use private networks. Keep development mode off on a public host.
Response caps are fixed per operation: DID/PLC 512 KiB, OAuth metadata 256 KiB, MCP metadata 64 KiB, external handle files 4 KiB, and proxy errors 64 KiB. `PDS_FETCH_MAX_RESPONSE_SIZE` is not an implemented setting.
## Invites and limits
| Variable | Meaning | Default |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | -------------------------- |
| `PDS_INVITE_REQUIRED` | Whether sign-up needs an invite code. | `true` in the example file |
| `PDS_INVITE_EPOCH`, `PDS_INVITE_INTERVAL` | The reference server’s per-account invites: from the epoch on, each account earns one code per interval, in milliseconds. | unset, no codes earned |
| `PDS_RATE_LIMITS_ENABLED` | The reference server’s rate limits, by client address and by account. | `true` |
| `PDS_RATE_LIMIT_BYPASS_KEY`, `PDS_RATE_LIMIT_BYPASS_IPS` | A header value, and addresses, that bypass the limits. | unset |
| `PDS_HCAPTCHA_SITE_KEY`, `PDS_HCAPTCHA_SECRET_KEY`, `PDS_HCAPTCHA_TOKEN_SALT` | hCaptcha on the sign-up page. All three or none. | unset |
The process also admits at most 8 uploads, 2 imports, 8 streamed exports, 32 firehose connections and 64 ordinary blocking jobs. Exhaustion returns 503 `ServerBusy`; a rate-limit bypass does not bypass these limits. Audit writes use four separate workers and wait for capacity. These limits are fixed in the implementation.
Request-body reads allow 15 seconds without progress and 300 seconds total; expiry returns 408 `RequestTimeout`. Exports have the same total deadline and a 15-second queue stall limit. Firehose sends may stall for 15 seconds; incoming frames and messages are capped at 64 KiB. Clients must discard an incomplete export and retry later. Refused bodies are drained for at most five seconds or the byte cap; an oversized body still returns 413 if draining times out.
## Mail
| Variable | Meaning |
| --------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
| `PDS_EMAIL_SMTP_URL` | The SMTP server, as a URL with the credentials. [Email](https://pds.linkjar.io/configure/email/) has the shape. |
| `PDS_EMAIL_FROM_ADDRESS` | The sender of the server’s mail. |
| `PDS_MODERATION_EMAIL_SMTP_URL`, `PDS_MODERATION_EMAIL_ADDRESS` | The sender of mail a moderation service sends to accounts through the admin API. Optional. |
## Branding
`PDS_LOGO_URL`, `PDS_PRIMARY_COLOR`, `PDS_ERROR_COLOR`, `PDS_WARNING_COLOR`, `PDS_SUCCESS_COLOR`, `PDS_INFO_COLOR`, `PDS_BACKGROUND_LIGHT_URL` and `PDS_BACKGROUND_DARK_URL` style the sign-in and sign-up pages, as on the reference server.
## New in LinkJar PDS
| Variable | Meaning | Default |
| ---------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| `PDS_PROFILE` | `stock` for the reference server’s behaviour, `linkjar` for LinkJar’s sign-in providers and policies. [Profiles](https://pds.linkjar.io/configure/profiles/). | `stock` |
| `PDS_METRICS_ADDRESS` | The private listener for Prometheus metrics. [Logs, health and metrics](https://pds.linkjar.io/operate/monitoring/). | unset, no listener |
| `PDS_OPS_ADDRESS`, `PDS_OPS_CLIENT_IDS` | The private listener of the operations console, and the console’s client id. [Console and MCP server](https://pds.linkjar.io/scale/sidecars/). | unset |
| `PDS_AUDIT_KEY_ED25519_PRIVATE_KEY_HEX` | The key that signs audit checkpoints. [Audit log](https://pds.linkjar.io/operate/audit-log/). | unset, checkpoints unsigned |
| `PDS_AUDIT_CHECKPOINT_REPO` | The DID of the account on this server that publishes the checkpoints. | unset |
| `PDS_POSTGRES_URL`, `PDS_POSTGRES_SCHEMA_PREFIX` | The shared databases on Postgres instead of SQLite files. [Postgres](https://pds.linkjar.io/scale/postgres/). | unset, `pds` |
| `PDS_ENTRYWAY_*`, `PDS_MEMBER_*` | A member host, or an entryway. [Entryway](https://pds.linkjar.io/scale/entryway/). | unset |
| `PDS_MCP_CLIENT_IDS`, `PDS_OAUTH_KNOWN_CLIENTS_FILE` | The MCP servers of this server, and OAuth clients known without a fetch. | unset |
| `LOG_LEVEL` | The log filter: `info`, `debug`, or a filter such as `info,pds_xrpc=debug`. | `info` |
The [specification’s Appendix C](https://github.com/linkjar/pds/blob/main/docs/SPEC.md#appendix-c-configuration) lists every accepted variable, including the ones this page leaves out.
# Handles and certificates
> Hosted handles under the server's name, handles on a domain of the account's own, and how Caddy decides which names get a certificate.
[Source](https://pds.linkjar.io/configure/handles/)
A handle is a domain name that resolves to an account’s DID. The server hosts handles under its own name, and an account can use a domain of its own instead.
## Hosted handles
`PDS_SERVICE_HANDLE_DOMAINS` lists the suffixes, each with a leading dot and separated by commas. The default is the server’s own name, so handles are `alice.pds.example.com`. Each suffix needs a wildcard DNS record at the host and a certificate for each handle.
To offer a second suffix, such as `.example.org`:
1. Add `.example.org` to `PDS_SERVICE_HANDLE_DOMAINS`: `.pds.example.com,.example.org`.
2. Point `*.example.org` at the host.
3. Add the names to the site block of the Caddyfile: `{$PDS_HOSTNAME}, *.{$PDS_HOSTNAME}, *.example.org`.
The server answers `/.well-known/atproto-did` for each hosted handle by the request’s `Host` header. Handles cannot end in `.alt`, `.arpa`, `.example`, `.internal`, `.invalid`, `.local`, `.localhost` or `.onion`, and the reference server’s reserved names are refused.
## Certificates on demand
Caddy does not hold a wildcard certificate. It asks Let’s Encrypt for a certificate the first time a client connects to a name, and before it asks, it calls the server’s `/tls-check?domain=`. The server says yes for its own name and for the handle of each active account, and no for every other name. A stranger who points a name at your host gets no certificate from it, and the server never uses up the rate limits of Let’s Encrypt on names it does not host.
The first request for a new handle waits a few seconds for the certificate. A deactivated or deleted account’s handle gets no new certificate.
## A handle on the account’s own domain
An account can use `alice.com` as its handle. Alice proves the domain is hers in one of two ways, then changes the handle in the app’s settings:
* A DNS record `_atproto.alice.com` of type `TXT` with the value `did=did:plc:…`, or
* the file `https://alice.com/.well-known/atproto-did` with the DID as its body.
The server checks DNS first and the file second; when both exist and disagree, DNS wins. The old hosted handle is released. The AT Protocol’s [handle guide](https://atproto.com/guides/identity#handles) has the detail for people on your server.
> **Keep the server off a shared domain**
>
> Serve the PDS on a domain of its own, not on a subdomain of a site that also serves a web app with an OAuth client. The blobs and the authorization pages of the server would otherwise share a parent domain with the app’s cookies.
# Profiles
> The stock profile reproduces the reference server. The linkjar profile adds LinkJar's sign-in providers and policies.
[Source](https://pds.linkjar.io/configure/profiles/)
Behaviour that varies per operator sits behind extension points in the server, and `PDS_PROFILE` selects a set of them. Everything else, from the repository engine to the firehose, is the same in both profiles.
## `stock`
The default. The server behaves as the reference server does: sign-up with an email address, a password and an invite code; sign-in with the password or an app password, or through OAuth; the reference server’s mail.
Most self-hosters want this one.
## `linkjar`
The profile LinkJar runs on its own hosts. It adds:
* Sign-in with Apple, Google and GitHub, from the sign-up and sign-in pages. Each provider needs `PDS_EXTERNAL__CLIENT_ID` and `PDS_EXTERNAL__CLIENT_SECRET`, for `APPLE`, `GOOGLE` and `GITHUB`.
* A handle policy: a handle suggested from the display name or the email address, 3 to 18 characters, with a suffix on collision, and one rename of a hosted handle within 30 days.
* An account page at `/account` with the sign-in methods, the sessions and the devices of an account, and a receipt of the sign-up that the LinkJar apps read.
* LinkJar’s mail templates, with a text alternative and no tracking.
* hCaptcha on the sign-up page when `PDS_HCAPTCHA_SITE_KEY`, `PDS_HCAPTCHA_SECRET_KEY` and `PDS_HCAPTCHA_TOKEN_SALT` are set. With hCaptcha on, new accounts come through the sign-up page only, and `createAccount` from the API is closed to them.
* Operator and moderator roles for the [console](https://pds.linkjar.io/scale/sidecars/).
The [specification’s section 13](https://github.com/linkjar/pds/blob/main/docs/SPEC.md#13-the-linkjar-profile) has every rule. Switch profiles with a restart; the data directory is the same for both.
# Command line
> Run operator commands with a native binary, the NixOS service, or Docker Compose.
[Source](https://pds.linkjar.io/operate/cli/)
Every installation uses the same `linkjar-pds` executable and commands. Except for `version`, `help`, and `audit verify`, commands read configuration from the environment. The binary does not automatically load `pds.env`. Use the same data paths, secrets, and service user as the server.
## Native services
The [native installation](https://pds.linkjar.io/start/native/) uses the `linkjar-pds` user, `/var/lib/linkjar-pds`, port `2583`, and `/etc/linkjar-pds/pds.env`. Systemd can load that root-owned file before switching to the service user. Define this shell helper on the host:
```bash
PDS_BIN=/usr/local/bin/linkjar-pds
pds() {
sudo systemd-run --quiet --wait --pipe --collect \
--property=Type=exec \
--property=User=linkjar-pds \
--property=Group=linkjar-pds \
--property=WorkingDirectory=/var/lib/linkjar-pds \
--property=EnvironmentFile=/etc/linkjar-pds/pds.env \
--property=UMask=0077 \
--setenv=PDS_DATA_DIRECTORY=/var/lib/linkjar-pds \
--setenv=PDS_PORT=2583 \
"$PDS_BIN" "$@"
}
```
For the NixOS example, set `PDS_BIN=/run/current-system/sw/bin/linkjar-pds` instead. It installs the same package used by the service on that path. If you changed the runtime file, data path, or port, change the helper too. If public settings live in `services.linkjar-pds.environment`, also pass them with `--setenv=NAME=value`. Use an explicit `SSL_CERT_FILE` when the host’s CA bundle is in a nonstandard location.
This helper uses a temporary service for each command. It waits for completion, returns the command’s exit status, and passes its output to your terminal. It does not start or stop the main PDS service. See the [systemd-run manual](https://www.freedesktop.org/software/systemd/man/latest/systemd-run.html) for these options.
```bash
pds check-config
pds verify --json
```
Do not run a second `serve` through this helper. Stop the main service before `audit seal` or `migrate-storage`. Run commands that write state as the service user so they do not leave root-owned database files.
For a foreground installation, use `linkjar-pds ` directly from the shell that holds its configuration and has access to its data.
## Docker Compose
Compose supplies the environment from `pds.env`. Against the running container:
```bash
docker compose exec pds linkjar-pds verify
```
With the main server stopped, run a command in a separate container:
```bash
docker compose run --rm pds linkjar-pds check-config
```
The configuration check can also run while the server is up. Storage migration and the initial audit seal require the main server to be stopped.
## Commands
| Command | Does |
| --------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `serve` | Serves the data directory. Run under your service manager. |
| `check-config` | Validates the configuration and exits. Prints `the configuration is valid`. |
| `verify [--json]` | Checks the data directory: each repository against its records and blobs. Reads only; prints a summary with the count of differences, lists each, and exits 1 when there is one. |
| `export-car ` | Writes one repository to standard output as a CAR file. |
| `audit seal` | Begins the audit log with a signed snapshot of the accounts, for a directory with history before the log. Refused on a log with entries. |
| `audit export [ []]` | Writes the audit log, or a range of entries, to standard output as a bundle. |
| `audit verify ` | Checks a bundle offline. Needs no configuration, so it runs on any machine with the binary. Exits 1 on a problem. |
| `migrate-storage --to postgres\|sqlite` | Copies the shared databases between the files of the data directory and Postgres, and compares the two. Runs only while no server does. |
| `reconcile [--remove-orphans]` | At an entryway, compares the accounts with the repositories of the member host. |
| `health` | Asks the server on this host for its health route. Also used by the container health check. |
| `version` | Prints the version. |
Standard output belongs to the result; logs go to standard error. For native services, redirect the helper’s output directly:
```bash
umask 077
pds audit export > audit-bundle.json
pds export-car did:plc:REPLACE_WITH_ACCOUNT_DID > account.car
```
For Docker, use `exec -T` so it allocates no terminal:
```bash
umask 077
docker compose exec -T pds linkjar-pds audit export > audit-bundle.json
```