@monaco_koukoku この問題はx-forwarded-fetchミドルウェアが設定されていないために発生しています。
詳しく説明させていただきますと:
fedify tunnelは、ローカルのHTTPサーバーをHTTPSで外部に公開するリバースプロキシとして動作します。- この過程で、元々のHTTPSリクエストはHTTPに変換されてローカルサーバーに転送されます。このとき、元のプロトコルとホスト情報は
X-Forwarded-ProtoおよびX-Forwarded-Hostヘッダーに含まれて転送されます。 - しかし、x-forwarded-fetchミドルウェアが設定されていない場合、Fedifyはこれらのヘッダーを認識できず、直接受け取ったHTTPリクエストのURLのみを参照することになります。
- その結果、
ctx.url.hrefがhttps://ではなくhttp://で始まるURLとなり、生成されるActorオブジェクトのURLもすべてhttp://から始まるものになってしまいます。
解決方法としては、以下のようにx-forwarded-fetchミドルウェアをインストールして適用する必要があります:
import { behindProxy } from "x-forwarded-fetch";
serve({
fetch: behindProxy(request => federation.fetch(request, { contextData: undefined }))
});
このように設定することで、FedifyがX-Forwarded-*ヘッダーを正しく認識し、https://のURLを生成するようになります。
また、この問題についてはFedifyの公式ドキュメントの「ローカルサーバーを外部に公開する」(Exposing a local server to the public)セクションにも詳しく説明があります。

ALT text
These tools behave like a reverse proxy, so basically the federation server cannot recognize if it is behind a reverse proxy, and if the reverse proxy is in HTTPS. So the federation server will generate HTTP URLs in the ActivityPub messages, which cause interoperability issues. In this case, you can use the x-forwarded-fetch middleware in front of the Federation.fetch() method so that the Federation object recognizes the proper domain name and protocol of the incoming HTTP requests. For more information, see How the Federation object recognizes the domain name section in the Federation document.
