概念

自定义域名后缀

假如,Mastodon 主节点域名 domain1.com,我在该域名下领有一个用户 user1@domain1.com

配置自定义域名后缀反对后,也能够通过 user1@domain2.com 搜寻到。该配置须要在主节点中设置 ALTERNATE_DOMAINS

自定义账号别名

假如,Mastodon 主节点域名 domain1.com,我在该域名下领有一个用户 user1@domain1.com

配置自定义账号别名反对后,能够通过 user2@domain2.com 搜寻到(即用户名和域名均可自定义)。

如果您想要一个属于本人的账号别名,但没有服务器的话,能够参考一下我的发电打算: https://afdian.net/a/willin

配置自定义域名后缀

1. 配置环境变量

首先查看 .env.production 环境变量中的 ALTERNATE_DOMAINS,配置正确,示例值:

LOCAL_DOMAIN=example1.comALTERNATE_DOMAINS=example2.com,example3.com

配置好重启 Mastodon 服务。

2.配置域名

以自定义域名 example2.com 为例,须要做 3 个 301 跳转的配置:

  • /.well-known/host-meta 跳转到 https://example1.com/.well-known/host-meta
  • /.well-known/webfinger 跳转到 https://example1.com/.well-known/webfinger
  • /.well-known/nodeinfo 跳转到 https://example1.com/.well-known/nodeinfo

传统配置

能够通过 Apache 或者 Nginx 的配置间接进行跳转。配置文件自行编写一下即可。

Serverless 配置

如果是 Serverless 服务,以 Cloudflare Pages 为例,为 example2.com 的利用创立 _redirects 文件:

/.well-known/host-meta* https://example1.com/.well-known/host-meta:splat 301/.well-known/webfinger* https://example1.com/.well-known/webfinger:splat 301/.well-known/nodeinfo* https://example1.com/.well-known/nodeinfo:splat 301

Cloudflare Redirect 跳转

能够在 Cloudflare Redirect Rules 中间接创立规定跳转。


收费有 10 条配额,照着上图创立 3 次即可。

设置自定义账号别名

如果您想要一个属于本人的账号别名,但没有服务器的话,能够参考一下我的发电打算: https://afdian.net/a/willin

该办法实践上来说并不需要在 example1.com 主站域名上进行额定配置。只须要自定义三个动态文件即可。

/.well-known/webfinger

{  "subject": "acct:user1@example1.com",  "aliases": [    "https://example1.com/user1",    "https://example1.com/users/user1"  ],  "links": [     {      "rel": "http://webfinger.net/rel/profile-page",      "type": "text/html",      "href": "https://example1.com/@user1"    },    {      "rel": "self",      "type": "application/activity+json",      "href": "https://example1.com/users/user1"    },    {      "rel": "http://ostatus.org/schema/1.0/subscribe",      "template": "https://example1.com/authorize_interaction?uri={uri}"    }  ]}

/.well-known/host-meta

<?xml version="1.0" encoding="UTF-8"?><XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">  <Link rel="lrdd" template="https://example1.com/.well-known/webfinger?resource=acct:user1@example1.com" /></XRD>

/.well-known/nodeinfo

{    "links": [        {            "rel": "http://nodeinfo.diaspora.software/ns/schema/2.0",            "href": "https://example1.com/nodeinfo/2.0"        }    ]}

进阶应用

应用该办法进写死了一个域名下的一个账号,如果须要多账号自定义域名的话。则须要应用动静接口来实现相似以上格局的响应。参考资料:

  • 主站探讨: https://github.com/mastodon/mastodon/issues/2668
  • 旧文档: https://guide.toot.as/guide/use-your-own-domain/