iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🤝

Setting up a PDS and Joining the Bluesky Federation (0.4.0-beta)

に公開
2024/10/12

Around February 23, 2024, it became possible for anyone to create their own Bluesky PDS (Personal Data Server) and connect to the Bluesky network (so-called Federation).

This article is written based on organized documentation and the knowledge shared by pioneers through study groups and blog posts. I am grateful for the information from many predecessors and the various public documents.

However, if you find any incorrect descriptions, please let me know.

What is a PDS?

Short for Personal Data Server, it is the place where data associated with an account is read, written, and primarily stored.

It is similar to what is called an "instance" in Mastodon or Misskey. However, in the AT Protocol used by Bluesky, its role is slightly different from those instances.

Roughly speaking, relay servers collect post data and account profiles from this PDS, which are then aggregated by a server called an "AppView" to create timelines and feeds.

What is Federation?

It refers to the mechanism that aggregates posts and reactions from multiple separate PDS servers, allowing users to receive posts and reactions from other PDSs and communicate through mutual conversations, follows, etc.

Bluesky connects using the specifications and concepts of the AT Protocol. In the diagram below quoted from the official documentation, the PDS is located at the bottom.

federation-architecture-diagram-5e4cb957a16f8d5d90325b53133ed0bf.png
(Source: Federation Architecture | Bluesky)

Please refer to the source link (in English) for a detailed explanation.

Previously, the only PDS available was ".bsky.social" provided by Bluesky Social. (It is actually partitioned internally.)

Now, individuals and organizations can prepare their own PDSs other than ".bsky.social" and connect them to the Bluesky network to communicate mutually across different PDSs.

For a more detailed explanation of the overall architecture, please refer to yamarten's slides and considerations. They will help increase your understanding.

What You Can Do with a PDS

A PDS itself is merely a storage location for account information such as posts, reactions, and follow relationships; it cannot control posts on timelines or feeds. (Though it can delete accounts and posts.)

Instead, similar to ".bsky.social", you can assign a unique domain to the PDS, and users can use its subdomains as their handles.

Potential Use Cases

For example, consider a news organization, "Company A."
Suppose Company A owns the domain media.example and usually delivers news articles at the URL https://www3.media.example.
Since media.example is a domain owned and operated by Company A, no one else can typically use it.

Company A sets up a PDS at .media.example.
By operating accounts and posting using handles ending in .media.example, it is guaranteed that the information is sent by Company A itself or someone belonging to it.

Company A could create accounts for each news category and post articles:

  • General News: news.media.example
  • Breaking News: breaking.media.example
  • Politics: economy.media.example
  • Business: biz.media.example
  • Culture: culture.media.example
  • Sports: sports.media.example

These are all operated on the same domain, making it clear at a glance that every account belongs to Company A.
When individuals belonging to the organization, such as reporters or announcers, send information, doing so from a Company A domain account clarifies their identity and prevents the spread of fake information by third parties. It's just like an email address.

Furthermore, even if an account is closed, it prevents "account swapping," where a third party later acquires the same handle to impersonate and deceive other users.

However, this is the same as operating an account with a custom handle on the existing ".bsky.social".

In that sense, the benefits of operating your own PDS may not be strongly felt at the moment. However, in the future, when multiple entities start operating parts corresponding to the Relays and AppViews in the diagram above, it will become possible to deliver posts to networks other than Bluesky.

In this case, even if changes occur in the AppView operated by Bluesky or if it is affected by political issues of a specific country or organization, the advantages of a decentralized SNS emerge, as you can remain unaffected by routing through a different AppView.

Setting Up a PDS

That was a long introduction, but let's get started with setting up a PDS.

First, prepare a server. According to the official documentation, it currently needs to be a Linux server.

The following specifications are recommended:

Item Requirement
OS Ubuntu 22.04
Memory (RAM) 2GB or more 1GB
CPU Cores 2 cores or more 1 core
Storage 40GB or more 20GB of free SSD space
CPU Architecture amd64 or arm64
Estimated Users 1-20 people

Note added October 12, 2024: The recommended specifications were lowered on February 27, 2024.

Additionally, you need to open ports 443/TCP (for TLS communication) and 80/TCP (used for SSL certificate issuance during handle subdomain resolution).

Decide on a Domain in Advance

Decide on the domain you will use for your PDS.

Bluesky also offers domain affiliates for custom handles (account.bsky.app). However, as of now (February 2024), domains purchased there are difficult to use or configure for purposes other than custom handles. Therefore, please purchase a domain from another domain registrar so that you can configure the DNS settings.

Configure DNS Settings

Once the domain is ready, configure the DNS.
In this guide, we assume that the domain pds.example will be used.

Installing the PDS

Log in to your server and execute the following installer command.

As shown below, you must use sudo to execute it with root privileges.

curl -fsSL https://raw.githubusercontent.com/bluesky-social/pds/main/installer.sh >installer.sh
sudo bash ./installer.sh

When you run it, instructions for DNS settings that need to be configured beforehand will appear, so follow them to set things up.

Enter your public DNS address (e.g. example.com):
Enter an admin email address (e.g. you@example.com):

Next, set the domain you will use for the PDS and the administrator's email address. The administrator's email address is used for the automatic issuance of SSL certificates when verifying the PDS itself or PDS handles (such as yourname.pds.example).

After inputting these, the installation of necessary software (Docker, SQLite, etc.) and initial configuration will be performed automatically. Firewall settings to open the required ports (80 and 443) for operation are also handled here.

========================================================================
PDS installation successful!
------------------------------------------------------------------------

Check service status      : sudo systemctl status pds
Watch service logs        : sudo docker logs -f pds
Backup service data       : /pds
PDS Admin command         : pdsadmin

Required Firewall Ports
------------------------------------------------------------------------
Service                Direction  Port   Protocol  Source
-------                ---------  ----   --------  ----------------------
HTTP TLS verification  Inbound    80     TCP       Any
HTTP Control Panel     Inbound    443    TCP       Any

Required DNS entries
------------------------------------------------------------------------
Name                         Type       Value
-------                      ---------  ---------------
example.com              A          Server's IP
*.example.com            A          Server's IP

Detected public IP of this server: Server's IP

To see pdsadmin commands, run "pdsadmin help"

========================================================================

After the installation is complete, a message like the one above will be displayed. In reality, the output will reflect your specific setup environment and configuration. It includes information on required settings for operation, administrator commands, and how to check logs, so be sure to review it.

Once this is complete, you will be asked whether you want to create your first account. You can create one as needed. Even if you don't create an account at this timing, you can create one at any time using the administrator commands that are installed simultaneously.

System Services

Additionally, a service named /etc/systemd/system/pds.service is created as a system service.
This allows you to start and stop the PDS as a service on the server.

# Start
sudo systemctl start pds

# Stop
sudo systemctl start pds

# Check status
sudo systemctl status pds

You don't necessarily have to use the commands above; since it is running as a Docker container, you can also simply restart the containers with docker compose.

Installation Directory

A directory has been created at /pds. PDS settings and account data are located within this directory.

Configuration Files

Settings for running the PDS are configured in /pds/pds.env. You can apply parameters by setting them as environment variables in this file.

PDS_HOSTNAME=pds.example
PDS_JWT_SECRET=0123456789abcdef0123456789abcdef
PDS_ADMIN_PASSWORD=abcdef0123456789abcdef0123456789
PDS_PLC_ROTATION_KEY_K256_PRIVATE_KEY_HEX=9a8b7c6d5e4f3219a8b7c6d5e4f3219a8b7c6d5e4f3219a8b7c6d5e4f3219a8b
PDS_DATA_DIRECTORY=/pds
PDS_BLOBSTORE_DISK_LOCATION=/pds/blocks
PDS_DID_PLC_URL=https://plc.directory
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
LOG_ENABLED=true

The default looks like the above.[1]
Please note that the top four lines are unique to your PDS and contain sensitive information.
The remaining lines specify which relays and AppViews the PDS interacts with. Currently, there is no need to change these.

You must restart the pds.service or the container to apply changes.

Email Server Settings

The PDS will function without these, but they are necessary for email address verification during account registration and for when an account owner needs to change their password.

By adding the following settings to /pds/pds.env, you can use features that require email notifications.

# SMTP configuration
_SMTP_USERNAME=smtp_user
_SMTP_PASSWORD=smtp_password
_SMTP_HOST=smtp.example.com
PDS_EMAIL_SMTP_URL=smtps://${_SMTP_USERNAME}:${_SMTP_PASSWORD}@${_SMTP_HOST}

You can use any email provider. Services such as Gmail, SendGrid, Mailgun, Mailjet, or Mailtrap are convenient.

Replace the values for _SMTP_HOST, _SMTP_USERNAME, and _SMTP_PASSWORD with those of the service you are using.
If the above format does not work correctly, try specifying the URI directly in PDS_EMAIL_SMTP_URL starting with smtps://.

Also, because it must be written in URI format, if your email provider issues an SMTP username as an ID like smtpuser@example.com, you must write it as a URL-encoded value such as smtpuser%40example.com.

Example: PDS_EMAIL_SMTP_URL=smtps://smtpuser%40example.com:smtp_password@smtp.example.com

pdsadmin

Once the installation is complete, an administrator command called pdsadmin becomes available.
This command is located in /usr/local/bin.

Since execution requires root privileges, you should run it as sudo pdsadmin when executing it as a regular user.

With pdsadmin, you can perform the following operations:

Account Operations

List Accounts

sudo pdsadmin account list

Displays a list of accounts on the PDS.

Create Account

sudo pdsadmin account create [email] [handle]

Creates an account on the PDS by entering an email address and a handle.

Delete Account

sudo pdsadmin account delete [did:plc:abcdef123456]

Deletes an account. Since the actual data is deleted, it cannot be restored.

Takedown Account (Freeze)

sudo pdsadmin account takedown [did:plc:abcdef123456]

Restricts the use of the specified user.
Posts and profile updates cannot be performed, and the account will become invisible to others.
If the user was logged in, they will be logged out.

Untakedown Account (Unfreeze)

sudo pdsadmin account untakedown [did:plc:abcdef123456]

Lifts the account freeze. Previous posts will be restored and visible to other accounts again.

Password Reset

sudo pdsadmin account reset-password [did:plc:abcdef123456]

Resets the password for a specific account.
A new password is issued immediately upon execution; use it to log in. If the account was logged in elsewhere, existing sessions will be logged out immediately.

Updating the PDS

sudo pdsadmin update

When a new version is released, you can use this command to update the PDS to the latest version.

Note: When you run this command, everything except for PDS settings, accounts, and data will return to the same state as immediately after installation. If you have modified compose.yml or other files, those changes will be reset.

Troubleshooting

Profile or posts not visible after logging in post-installation

  • Note added October 12, 2024: Since around April 25, 2024, connection requests via Discord are no longer required!
    • PDSs created before then that hadn't applied can now be used as-is.
  • Currently, federation is open for developers, and it is set up so that you don't connect to the Bluesky network immediately.
  • As of February 2024, to connect a PDS to the relay, you need to join the Discord server linked in the official documentation, AT Protocol PDS Admins, and submit a request.
    • Approval seems to be a manual process currently, which may take anywhere from a few minutes to several hours.
    • This application process is expected to become unnecessary in the future.
    • Once connection is permitted, you will be able to see your profile and perform posts or browsing.
    • This Discord server also provides support for PDS configuration.
    • Additionally, a Japanese channel has been set up thanks to a call from volunteers. [2]

Other people's posts are visible, but my own posts or likes aren't reflected. Could it be that it's not being crawled?

  • You can request the Bluesky relay to find you using the following command:
sudo pdsadmin request-crawl https://bsky.network
  • If successful, it will start fetching data, and it will begin appearing on the timeline.
  • If it still doesn't appear, check if your reverse proxy server supports WebSocket connections. [3]

PDS account handle is displayed as "Invalid Handle"

  • PDS handles are verified via the web. Accessing https://<handle>/.well-known/atproto-did should return the DID as text for successful verification.
  • Using Bluesky Debug provided by the Bluesky official team makes it easier to find issues.

Restrictions in PDS operation

  • Although federation has begun, PDS federation is still in the developer preview phase.
  • Currently, the following restrictions are imposed on unofficial PDSs by the operators: [4]
    • Up to 10 accounts per PDS
    • 1,500 events per hour
    • 10,000 events per day
  • It might take a little more time before you can fully invite friends, acquaintances, or community members to use it.

Other

Other Settings

Although it is slightly older than the 0.4.0-beta released this time, please also refer to the previously posted Setting up a Bluesky PDS (0.3.0-beta).

Settings such as:

  • Email sending settings
  • Presence of invitation codes during account creation
  • Automatic distribution interval for invitation codes
  • How to set Terms of Service and Privacy Policy displayed during PDS registration

are also described.

Customizing the Execution Environment

I have published partially customized operational configurations on GitHub, so please feel free to refer to these as well.

In the following repository, I am trying to create an environment that runs with Cloudflare + nginx + PDS (0.4.0).

https://github.com/anon5r/mypds

By separating settings and data storage areas, you can also run multiple PDSs simultaneously on a single machine.

Conclusion

Thank you for reading until the end.

I had just started playing around in the sandbox right when federation was about to begin on Bluesky, so I was impressed by how easily I could set up a PDS after updating and configuring it. When trying to customize fine details, there were some points where I got stuck without knowing what to do, but with the help of the support community and others, I was able to get everything running. I wrote this for my own understanding and organization.
I also referred extensively to documentation and knowledge articles from pioneers who had been verifying things in the sandbox environment ahead of time.

Bluesky itself is still under development, so things may change from here on out, but for now, I hope that the start of federation will lead to more excitement.

Finally, if you have any suggestions, such as misunderstandings or incorrect descriptions in the article, I would appreciate it if you could leave a comment.


Update History

  • Added note that connection requests via Discord are no longer required (2024/10/12 16:40)
  • Updated recommended environment specifications for PDS (2024/10/12 16:26)
  • Changed typos and some confusing descriptions. Added AT Protocol explanation and links to future consideration articles. (2024/02/26 19:45)
  • Initial version published (2024/02/26 11:49)
脚注
  1. The secrets, passwords, and rotation keys listed are all dummy values. ↩︎

  2. Nighthaven, thank you for the initiative! ↩︎

  3. When the author replaced it with nginx, this setting was missed, and it took about a day to resolve... ↩︎

  4. Stated within the AT Protocol PDS Admins Discord channel ↩︎

Discussion