Flake to setup a local env for atproto development

Add relay

edouard.paris cd4581c9 1275c130

verified
Changed files
+64 -34
packages
+45 -27
README.md
···
A Nix-based development environment for running AT Protocol services (PDS, PLC, Caddy proxy, and MailHog).
+
## ⚠️ Security Warning
+
+
**This environment uses a modified AT Protocol relay with SSRF protection disabled.**
+
+
- The relay is built from a forked repository (`edouardparis/indigo`) with SSRF (Server-Side Request Forgery) protections disabled
+
- Custom ports are allowed without restrictions
+
- **This configuration is ONLY safe for local development environments**
+
- **DO NOT use this relay configuration against external hosts or in production**
+
- **DO NOT expose this relay to the internet**
+
+
This setup is designed for controlled local testing where you need flexibility in network access that would normally be restricted for security reasons.
+
## Prerequisites
-
Make sure to add these lines to your `/etc/hosts` file:
-
```
-
127.0.0.1 pds.example.org
-
127.0.0.1 plc.example.org
-
127.0.0.1 relay.example.org
-
```
+
1. **Install mkcert** (required for SSL certificate generation):
+
- On macOS: `brew install mkcert`
+
- On Linux: See [mkcert installation guide](https://github.com/FiloSottile/mkcert#installation)
+
- After installation, run: `mkcert -install`
-
Generate SSL certificates before first use:
-
```bash
-
nix run .#generate-certs
-
```
+
2. **Add hosts file entries:**
+
```
+
127.0.0.1 pds.example.org
+
127.0.0.1 plc.example.org
+
127.0.0.1 relay.example.org
+
```
+
+
3. **Generate SSL certificates before first use:**
+
```bash
+
nix run .#generate-certs
+
```
## Quick Start
···
- Pane 2: Caddy proxy
- Pane 3: AT Protocol Relay
-
3. **Create an invite code:**
+
3. **Add PDS host to the relay:**
+
```bash
+
goat relay --relay-host=https://relay.example.org:8445 admin --admin-password=password host add "https://pds.example.org:8443"
+
```
+
+
4. **Create an invite code:**
```bash
scripts/create-invite.sh
```
-
4. **Create a user account:**
+
5. **Create a user account:**
```bash
goat account create \
--pds-host=https://pds.example.org:8443 \
···
--handle=edouard.pds.example.org
```
-
Expected output:
-
```
-
Success!
-
DID: did:plc:pzvsc3jwfjwidojtpbxv4rdd
-
Handle: edouard.pds.example.org
-
```
-
-
5. **Verify the DID is registered:**
+
6. **Verify the DID is registered:**
```bash
-
goat --plc-host=https://plc.example.org data did:plc:pzvsc3jwfjwidojtpbxv4rdd
+
goat plc --plc-host=https://plc.example.org data <your-did>
```
-
6. **Login to your account:**
+
7. **Login to your account:**
```bash
goat account login \
--username=edouard.pds.example.org \
···
--pds-host=https://pds.example.org:8443
```
-
7. **Create your first post:**
+
8. **Create your first post:**
```bash
goat bsky post "hello world!"
```
···
- **AT Protocol Relay**: https://relay.example.org:8445
- **MailHog**: http://localhost:8025
-
## Available Tools
+
## Monitoring
-
- `goat` - AT Protocol CLI tool
-
- `curl`, `jq` - HTTP and JSON utilities
-
- `tmux` - Terminal multiplexer
+
To monitor the AT Protocol relay firehose:
+
```bash
+
goat firehose --relay-host wss://relay.example.org:8445
+
```
+
+
This will show real-time events from the relay. You can run this in a separate terminal or tmux pane.
## Management Commands
+16 -4
flake.nix
···
tmux split-window -v -t atproto "${caddy-proxy}/bin/caddy-proxy"
# Split vertically for Relay (with environment variables)
-
tmux split-window -v -t atproto "RELAY_ADMIN_PASSWORD=password RELAY_PLC_HOST=https://plc.example.org:8444 RELAY_TRUSTED_DOMAINS=*.example.org RELAY_ALLOW_INSECURE_HOSTS=true ${indigo-relay}/bin/relay serve"
+
tmux split-window -v -t atproto "
+
export RELAY_ADMIN_PASSWORD=password
+
export RELAY_PLC_HOST=https://plc.example.org:8444
+
export RELAY_TRUSTED_DOMAINS=*.example.org
+
export RELAY_ALLOW_INSECURE_HOSTS=true
+
export RELAY_LOG_LEVEL=debug
+
export RELAY_DISABLE_SSRF=true
+
export RELAY_ALLOW_CUSTOM_PORTS=true
+
${indigo-relay}/bin/relay serve
+
"
-
# Make all panes equal size
-
tmux select-layout -t atproto even-vertical
# Select the first pane
tmux select-pane -t atproto.0
···
echo " tmux attach -t atproto - Attach to the session"
echo " tmux kill-session -t atproto - Stop all services"
echo ""
-
echo "📋 Panes layout (single column):"
+
echo "📋 Panes layout:"
echo " • Pane 0: PLC server"
echo " • Pane 1: PDS server"
echo " • Pane 2: Caddy proxy"
echo " • Pane 3: AT Protocol Relay"
echo ""
echo "💡 Use Ctrl+b followed by arrow keys to switch between panes"
+
echo "💡 To monitor firehose: goat firehose --relay-host wss://relay.example.org:8445"
'';
# Script to start relay with environment
···
export RELAY_PLC_HOST="https://plc.example.org:8444"
export RELAY_TRUSTED_DOMAINS="*.example.org"
export RELAY_ALLOW_INSECURE_HOSTS="true"
+
export RELAY_LOG_LEVEL="debug"
+
export RELAY_DISABLE_SSRF="true"
+
export RELAY_ALLOW_CUSTOM_PORTS="true"
${indigo-relay}/bin/relay serve
'';
···
echo " nix run .#plc - Start PLC server"
echo " nix run .#pds - Start PDS server"
echo " nix run .#caddy-proxy - Start Caddy proxy"
+
echo " nix run .#relay - Start AT Protocol Relay"
echo " nix run .#mailhog - Start MailHog"
echo " nix run .#generate-certs - Generate SSL certificates"
echo ""
+3 -3
packages/indigo-relay.nix
···
version = "unstable-2024-10-03";
src = fetchFromGitHub {
-
owner = "bluesky-social";
+
owner = "edouardparis";
repo = "indigo";
-
rev = "master"; # Latest commit from master branch
-
hash = "sha256-yVj7DKGAUXQO4eTu4reAtm7bTE4ab0jYGX2ba74qazU=";
+
rev = "disable-ssrf-and-allow-custom-ports";
+
hash = "sha256-0Uy/7IT3gVVkfntXauue07O6WDhmU+heNT4fSh+sK5A=";
};
vendorHash = "sha256-7mYvgvR0tZdEnUgUYzKv6d2QyeXXnrFgVwY8/4UM3oU=";