Last active
April 30, 2023 22:00
-
-
Save agrueneberg/5693181 to your computer and use it in GitHub Desktop.
A simple WebFinger resource for nginx (compatible with draft-ietf-appsawg-webfinger-14.txt).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location ~ /.well-known/webfinger { | |
add_header 'Access-Control-Allow-Origin' '*'; | |
if ($arg_resource = "") { | |
return 400; | |
} | |
try_files /profiles/$arg_resource.json =404; | |
} |
Note that nginx doesn't decode URL parameters, so the file names have to be URL encoded as well: ?resource=acct%3Abob%40example.com
will look for a file called /profiles/acct%3Abob%40example.com.json
. I suggest symlinks as a workaround to accept unencoded resource
parameters.
There is now a dedicated repository for this: https://github.com/agrueneberg/nginx-webfinger Please report issues there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add
application/json json;
to/etc/nginx/mime.types
to serve the files with the rightContent-Type
. Optionally, addapplication/json
tocharset_types
if you want to specify the charset in theContent-Type
.