Sending and Receiving Webmentions with Kineto and nginx
Author: -fab- <fab@redterminal.org>
License: CC BY-SA 4.0
Published on: Wed, 12 Feb 2025 02:08:53 +0100
Last updated: Wed, 12 Feb 2025 02:08:53 +0100
I'm developing a little bash script to send Webmentions manually. You can use it if you use for example kineto as a gemini2web proxy on your site and inject the webmention entpoint link at the beginning of each page. This is possible for example with the "subfilter" command in the nginx config. This way you can send and receive webmentions. Of course you need a webmention.io account first.
webmention.io - Receive webmentions on supporting sites (www)
Example Configuration for nginx from my webserver
There are far to many possibilities how to set up a webserver with kineto so here is just my location directive for my kineto proxy with the needed links in my nginx config.
server_name redterminal.org;
location / {
proxy_pass http://127.0.0.1:8080; # Kineto Address
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
# now comes the sub_filter command which replaces a string
# with another one on each page under the location.
# Not all <link> tags are neccessary, just the last two.
sub_filter '</title>'
'</title>\n
<link rel="me" href="mailto:fab@redterminal.org" />\n
<link rel="me" href="https://pleroma.envs.net/@fab" />\n
<link rel="me" href="https://codeberg.org/fab/" />\n
<link rel="me" href="https://keyoxide.org/fab@redterminal.org" />\n
\n
<link rel="webmention" href="https://webmention.io/<YOUR LOGIN NAME>/webmention" />\n
<link rel="pingback" href="https://webmention.io/<YOUR LOGIN NAME>/xmlrpc" />\n';
}
I use RSS to receive my Webmentions. For this you create an account at webmention.io and then look under "settings" and find the API key and the mention feed links to put into your RSS reader:
https://webmention.io/api/mentions.atom?token=<your API key>
So you receive all Webmentions via RSS and you can then later add those received links to your gemini page, which received the mention (if you want).
Sending Webmentions manually with webmention.sh
As I told above I've written a little bash script to send Webmentions manually. But be aware, that there *MUST* be a link back to the site you want to send the mention to on your own page!
Codeberg.org git repo of the webmention.sh script (www)
It's based on some example code from the indieweb.org wiki, it just has better regular expressions to find the right Webmention endpoint link, which sometimes can be tricky.
To send a Webmention with my script run the following command:
./webmention.sh <your-url> <target-url>
That's all! Of course you have to use the http(s) links and not the gemini links with the script. If you made no typos, linked back to the receiving page (which you did, or?) and set up everything right, you should get some response, that your Webmention is queried for procession. You sent your first webmention!
The script waits 10 seconds to let the Webmention endpoint process the request. It then outputs a small summary of the request.
Final words
So if everything went ok and you made no typos you should now be able to send and receive Webmentions. If you have problems with the script or found a bug, you can write me on Mastodon/ActivityPub to <@fab@pleroma.envs.net> or send an email to <fab@redterminal.org> if you wish.
All in all - Have fun!
-fab-
--
Back to index
Homepage