惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
D
DataBreaches.Net
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
V
Visual Studio Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
Recent Announcements
Recent Announcements
The Register - Security
The Register - Security
S
Secure Thoughts
Y
Y Combinator Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 最新话题
V2EX - 技术
V2EX - 技术
腾讯CDC
GbyAI
GbyAI
G
Google Developers Blog
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
T
The Exploit Database - CXSecurity.com
T
Threat Research - Cisco Blogs
P
Proofpoint News Feed
Schneier on Security
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
Jina AI
Jina AI
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
MyScale Blog
MyScale Blog
Help Net Security
Help Net Security
K
Kaspersky official blog
P
Privacy & Cybersecurity Law Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
AI
AI
MongoDB | Blog
MongoDB | Blog
Scott Helme
Scott Helme
J
Java Code Geeks
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
H
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
云风的 BLOG
云风的 BLOG
Microsoft Azure Blog
Microsoft Azure Blog
S
Security Affairs
TaoSecurity Blog
TaoSecurity Blog
The GitHub Blog
The GitHub Blog
Hacker News: Ask HN
Hacker News: Ask HN
Martin Fowler
Martin Fowler
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Project Zero
Project Zero
T
The Blog of Author Tim Ferriss
Last Week in AI
Last Week in AI

Dallas Lu

OpenWRT 使用 udp2raw 对抗 WireGuard 阻断 博客程序架构的思考与展望 如何证明你是原创作者 Nginx 泛域名配置的隐患与对策 WISeID S/MIME 证书 V2EX 刑满释放记 使用 Radicale 在 Ubuntu 24.04 中搭建 vCards CardDav 服务 邮件服务的域名成功从 SURBL 黑名单移除 网站多语言的设计细节 网站评论系统的目前进展和展望 在公网使用 iptables 转发端口时保留客户端 IP 邮件投递平台 Postal 的使用经验 自建 Postal 完美替代 SendGrid 互联网在崩塌吗,然后呢 在 SvelteKit 应用中使用 JSON-LD 网页的打印样式应该怎么写 “茴字的四种写法”之 IP 与域名 怎么伪造 Git 提交的时区 供大众交流的论坛和其它替代产品还是不好用 改编不是照搬 一次排查诡异的网络问题的经历 在 OpenWRT 23 中使用 nftset 配置 Shadowsocks 规则 使用自建 Tabby Web 来同步 Tabby 配置 手动建立自己的 IPv6 Tunnel 服务 在 PVE 手动配置网络及虚拟机 IPv6 公网 在 PVE 中缩小 Ubuntu 虚拟机的磁盘 Beancount 摊销与折旧的使用以及相关插件 Nginx 反代 Apache Subversion 添加 HTTPS Firefox 和 Chrome 为何要革 EV 证书的命
使用你的主域名作为 Mastodon 实例名
达拉斯・卢 · 2020-11-10 · via Dallas Lu

如果你有一个自建的博客,并且打算或已经建立一个 Mastodon 实例,那么就不得不面对一个域名选择的问题了。假设你的博客是 example.com,那么你的 Mastodon 账号应该是 yourname@example.com 还是 yourname@mastodon.example.com

为了简单明了,你自然更希望博客域名和 Mastodon 域名是同一个。但是 Mastodon 无法运行在二级目录下。即使通过反代等手段,把 Mastodon 的 web 部分,转移到了某个二级域名或目录下,那么作为一个去中心化的服务,在与联邦宇宙其他实例节点交换数据时,很可能发生未知的问题。

幸运的是,联邦节点间通信的重要一步是访问 https://example.com/.well-known/host-meta,这个文件的内容中包含了供后续步骤使用的 URL。而且 Mastodon 也支持 LOCAL_DOMAIN WEB_DOMAIN 两个选项。

配置 Mastodon

编辑 .env.production,进行如下修改:

  1. __不要__修改 LOCAL_DOMAIN
  2. 添加 WEB_DOMAIN 配置,设置为一个二级域名,比如 mastodon.example.com

配置 mastodon.example.com

参考 Mastodon 文档,为 mastodon.example.com 配置一个 nginx 主机。重启 Mastodon 的 streaming/sidekiq/web 服务,重新载入 nginx 配置,现在 mastodon.example.com 已经可以访问了。

配置 example.com

但是外部实例尝试连接你的账号 yourname@example.com 时,尚不知晓你的地址是 mastodon.example.com,所以我们希望访问 https://example.com/.well-known/host-meta 时能返回 https://mastodon.example.com/.well-known/host-meta 的内容。

example.com 的 nginx 配置中,移除 Mastodon 的配置,仅添加如下规则:

location = /.well-known/host-meta {
       return 301 https://mastodon.example.com$request_uri;
}

重新载入 nginx 即可。

更多配置

以上配置均来自于 felx 的补充文档 Using a different domain name for Mastodon and the users it serves。正如文中所说,尽管通过主域名跳转和 WEB_DOMAIN 配置,能够实现需求,但因为实例版本不一、客户端种类繁杂,难免仍会有奇怪的问题发生。

而且将已经运行了一段时间的 Mastodon 从主域名切换到二级域名,可能会有更明显的问题。

根据官方文档中的 Routes 章节,以及使用经验,建议为 example.com 设置如下规则,增加兼容性:

## mastodon web url
location ~ ^/(about/more|settings|web|pghero|sidekiq|admin|interact|explore|public|@.*|relationships|filters|terms|inert.css){
        rewrite ^(.*) https://$mastodon_host$1 permanent;
}

## mastodon .well-known
location ~ ^/(.well-known/(host-meta|nodeinfo|webfinger|change-password|keybase-proof-config)|nodeinfo) {
        rewrite ^(.*) https://$mastodon_host$1 permanent;
}

## mastodon system resources
location ~ ^/(system|headers|avatars) {
        ## set your mastodon public folder, or just redirect to $mastodon_host
        #rewrite ^(.*) https://$mastodon_host$1 permanent;
        root /home/mastodon/live/public;
}

## mastodon url (possible use post)
location ~ ^/(api/v1|inbox|actor|oauth|auth|users){
        return 308 https://$mastodon_host$request_uri;
}

现在可以用 yourname@example.com 来嘟嘟了。