/Webfinger Plugin

Webfinger Plugin

2
v0.3.5

Traefik WebFinger Plugin

Traefik WebFinger

A Traefik middleware plugin that implements the WebFinger Protocol (RFC 7033) for service discovery.

Features

  • Full WebFinger protocol support according to RFC 7033
  • Static resource configuration
  • Domain-based resource filtering
  • Optional passthrough to backend services
  • Support for multiple resource types (acct:, https://, mailto:)
  • Configurable aliases and links
  • JRD+JSON response format

Installation

To configure the WebFinger plugin in your Traefik instance:

  1. Enable the plugin in your static configuration:
# Static configuration
experimental:
plugins:
webfinger:
moduleName: github.com/NX211/traefik-webfinger
version: v0.1.0
  1. Configure the middleware in your dynamic configuration:
# Dynamic configuration
http:
middlewares:
my-webfinger:
plugin:
webfinger:
domain: "example.com"
resources:
"acct:user@example.com":
subject: "acct:user@example.com"
aliases:
- "https://example.com/user"
links:
- rel: "http://webfinger.net/rel/profile-page"
type: "text/html"
href: "https://example.com/user"
- rel: "self"
type: "application/activity+json"
href: "https://example.com/users/user"
passthrough: false
  1. Use the middleware in your router:
http:
routers:
my-router:
rule: "Host(`example.com`)"
service: my-service
middlewares:
- my-webfinger

Configuration

Plugin Configuration Options

OptionTypeRequiredDefaultDescription
domainstringYes""The domain this WebFinger service handles
resourcesmapNo{}Map of WebFinger resources and their responses
passthroughboolNofalseWhether to pass through to backend when resource not found

Resource Configuration

Each resource in the resources map can have the following properties:

PropertyTypeRequiredDescription
subjectstringYesThe resource identifier
aliases[]stringNoAlternative identifiers for the resource
links[]LinkNoRelated links for the resource

Each link in the links array can have:

PropertyTypeRequiredDescription
relstringYesThe link relation type
typestringNoThe content type of the linked resource
hrefstringNoThe URL of the linked resource
titlesmap[string]stringNoTitles in different languages
propertiesmap[string]stringNoAdditional properties

Example Usage

Basic Configuration

http:
middlewares:
webfinger:
plugin:
webfinger:
domain: "example.com"
resources:
"acct:alice@example.com":
subject: "acct:alice@example.com"
aliases:
- "https://example.com/alice"
links:
- rel: "http://webfinger.net/rel/profile-page"
type: "text/html"
href: "https://example.com/alice"

Making Requests

To query a WebFinger resource:

curl "https://example.com/.well-known/webfinger?resource=acct:alice@example.com"

Example response:

{
"subject": "acct:alice@example.com",
"aliases": [
"https://example.com/alice"
],
"links": [
{
"rel": "http://webfinger.net/rel/profile-page",
"type": "text/html",
"href": "https://example.com/alice"
}
]
}

Development

To build and test the plugin:

# Run tests
go test ./...
# Build the plugin
go build ./...

Local Development

For local development, you can use Traefik's plugin development mode:

# Static configuration
experimental:
localPlugins:
webfinger:
moduleName: github.com/NX211/traefik-webfinger

License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.