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

推荐订阅源

F
Full Disclosure
WordPress大学
WordPress大学
小众软件
小众软件
Cloudbric
Cloudbric
AWS News Blog
AWS News Blog
腾讯CDC
量子位
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
Vulnerabilities – Threatpost
Scott Helme
Scott Helme
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
C
CXSECURITY Database RSS Feed - CXSecurity.com
The Hacker News
The Hacker News
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
IT之家
IT之家
Jina AI
Jina AI
Attack and Defense Labs
Attack and Defense Labs
S
SegmentFault 最新的问题
Simon Willison's Weblog
Simon Willison's Weblog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
博客园 - 【当耐特】
Google Online Security Blog
Google Online Security Blog
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
罗磊的独立博客
L
LINUX DO - 最新话题
博客园 - Franky
博客园 - 叶小钗
Apple Machine Learning Research
Apple Machine Learning Research
The Last Watchdog
The Last Watchdog
J
Java Code Geeks
AI
AI
C
Cisco Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Cyber Attacks, Cyber Crime and Cyber Security
Cisco Talos Blog
Cisco Talos Blog
博客园 - 三生石上(FineUI控件)
雷峰网
雷峰网
Help Net Security
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
云风的 BLOG
云风的 BLOG
I
Intezer
S
Securelist

KittenLabs

Casiomania Marantz UD5007 power supply replacement AnotterKiosk GPD Pocket 4 Speaker DSP IP-over-Toslink FX3 LVDS Frame grabber Extreme Pi Boot Optimization WiFi auth with OsmoHLR/SIM cards Windows 11 tweaks & usability improvements 25GBit/s on macOS & iOS Router overclocking Real gaming router Manage RDP certificates on Windows using SSH 20 port USB-C charger Reviving a dead Gigabyte MJ11-EC1 mainboard NVMe BIOS Option ROM 2.5GbE PCIe NIC mod board Blinkekatze ThinkPad T41/T43 USB-C HomeSwitch 4 DC UPS (Lithium) OLED nametag Thermal camera macro LPT printer emulator PC104 ISA adapter Palm IIIc USB-C OtterCast Gigaset DECT debug adapter M.2 NVMe -> miniPCIe Analog floppy synthesizer Dead TROTEC PAC2000S air conditioner Typewriter Teletype SolarCamPi Palm IIIc LED backlight IrDA to RS232 RGB LED nametag PlutoSDR standalone ADS-B FR24 feeder Five meter LED wall ATAPI Audio-CD player TCP/IP for Casio calculators eMMC (micro)SD card ISA8019 NIC Programmable logic in PHP Micro8088 build log ISA-over-USB FlexibleLOM PCIe adapter Graphical 128x64px VFD GPIO PATA/IDE on Linux CMM2 PCB OpenWRT als WireGuard-Appliance NeonMatrix Pinebook Pro M.2 WiFi Environmental sensor GPS locked Raspberry Pi Es'hail-2 transceiver setup ThinkPad PowerSeries 820 PlutoSDR clock input WiFi over satellite TV coax Search Results
Using custom domains as a Fediverse redirect
By Manawyrm | Tuesday, May 28, 2024 · 2024-05-28 · via KittenLabs

Use your own domain name as a redirect to an existing account without running your own instance

Why?

Many people already use custom domains for their blog, e-mail, etc.
As the format of e-mail and fediverse accounts is basically identical, it would be ideal to be able to find Fedi users via their “normal” username@domain.tld address:

iOS fediverse client, searching for sarah@kittenlabs.de

Background

When searching for a specific account via the search function in (for example) Mastodon, the server executes a HTTP GET request like this:

"GET /.well-known/webfinger?resource=acct:sarah@kittenlabs.de HTTP/1.1" 404 11140 "-" "http.rb/5.1.1 (Mastodon/4.2.8; +https://chaos.social/)"

This mechanism is called WebFinger. This spec was extended with an ActivityPub-specific extension.

When this request is sent to a real ActivityPub instance, the server responds like this:

{
    "subject": "acct:manawyrm@chaos.social",
    "aliases": [
        "https://chaos.social/@manawyrm",
        "https://chaos.social/users/manawyrm"
    ],
    "links": [
        {
            "rel": "http://webfinger.net/rel/profile-page",
            "type": "text/html",
            "href": "https://chaos.social/@manawyrm"
        },
        [....]
    ]
}

Instead of hosting our own instance, we can just use simple HTTP 302 redirects for this URL to make our existing accounts discoverable from our custom domain. This does not create an alias, so our account will still be called account@instance.tld, not account@customdomain.tld.

Simple setup (one account for the whole domain)

If you only have one Fediverse account for the whole domain name, you can use a hack and just redirect all accesses to “/.well-known/webfinger” to your own instance.

Example Apache2 webserver configuration (can be applied in .htaccess or the server config):

RewriteEngine On
RewriteRule ^.well-known/webfinger https://chaos.social/.well-known/webfinger?resource=acct:manawyrm@chaos.social [R=302,L]

This will reply to all requests with a HTTP 302 (non-permanent!) redirect to our existing instance.
Remember to change both the domain name and the acct:-string.
The limitation of this method is that the query string/GET parameter isn’t getting parsed – every local part will get redirected to your account.

Advanced setup (using PHP)

Instead of redirecting directly to the existing ActivityPub instance, we can introduce another redirection and redirect the requesting instance to a custom script.

This can be written in any language of your choosing, of course. It only has to parse the resource GET parameter and reply either with a 302-redirect or a 404 error. For simple configurations, this can probably also be accomplished with very creative webserver configurations.

Every domain we want to use can be forwarded to our script:

RewriteEngine On
RewriteRule ^.well-known/webfinger https://mywebserver.de/activitypub-redirect/webfinger.php [R=302,L]

My webfinger.php looks like this:

<?php
switch (strtolower($_GET["resource"] ?? ''))
{
  case 'acct:user1@manawyrm.de':
  case 'acct:user1@kittenlabs.de':
    header("Location: https://existing-instance.tld/.well-known/webfinger?resource=acct:user1@existing-instance.tld");
    break;

  case 'acct:user2@kittenlabs.de':
    header("Location: https://existing-instance.tld/.well-known/webfinger?resource=acct:user2@existing-instance.tld");
    break;

  default:
    http_response_code(404);
    echo "404";
    break;
}

The switch-case statement can be expanded to support very advanced setups, of course.
It would be possible to use PHP to lookup the username in a database or even execute a full LDAP lookup and return the appropriate user account!

Hugo (static site generator)

When serving Hugo pages via Apache2, the hugo-apache-headers plugin can be used to generate the .htaccess file.

This plugin just needs a data/redirects.yaml file like this to generate a proper redirect:

redirects:
  - from: /.well-known/webfinger
    to: https://mywebserver.de/activitypub-redirect/webfinger.php

This will generate a 301 (permanent) redirect instead of a 302 (temporary) redirect, but it’ll still work.