I recently changed my web host to Mythic Beasts, mainly because they have a service allowing you to provision a Raspberry Pi and have them host it 24/7 for you. I wanted to host a fediverse instance on a Pi but didn’t fancy opening up an incoming port into my home network. So obviously this was an ideal use case for a remote Pi.
There is a catch… the Pi is IPv6 only. But in 90% of cases, this is fine because Mythic Beasts have a proxy that can be used to make one of my domains point to the Pi. The software I chose to use is Pleroma, because it’s designed to be lightweight and the docs actually advertise the fact that it runs on a Pi. I can confirm that it does. But I couldn’t get it to federate and just kept getting HTTP errors whenever I tried.
The only errors I got were Error fetching user
or Can't find user
in the web UI, and Could not decode user at fetch (...), :econnrefused
in the journalctl logs. Googling these errors wasn’t particularly helpful because, as it turned out, the problem was due to my very specific configuration of a Raspberry Pi 3 running Pleroma on an IPv6-only internet connection.
After hours of googling what I thought was the problem, I discovered that Pleroma uses a component called Hackney to do outgoing HTTP, and Hackney is IPv4-biased. By this I mean it looks up a domain name, and if it has an IPv4 address it tries to connect to that, only attempting IPv6 if it can’t get an IPv4 address. So what was happening is that Pleroma was trying to connect to other instances by host name, which were resolving to IPv4 addresses, which the Pi couldn’t connect to, as it has no IPv4 address.
There are lots of possible ways to fix this, all with disadvantages.
- Pay for a static IPv4 address, incurring extra monthly costs
- Modify the Pleroma (and probably Hackney) code to force it to default to IPv6, making future upgrades more difficult than they need to be
- Install inet64_tcp, making Erlang apps (Pleroma is one) all support IPv6, requiring me to learn how to use Erlang
What I actually did was…
- Install an ad-blocking proxy on localhost and configure Pleroma to use that for outgoing HTTP
This is hacky as hell, but it worked. I used Privoxy because it’s really simple to set up.
apt-get install privoxy
then modify the Pleroma config to use 127.0.0.1:8118
(Privoxy’s default) as an HTTP proxy. That’s it! Now, because Privoxy has taken charge of all the DNS nonsense, Pleroma has no say in whether it gets told to connect to IPv4 or IPv6. Of course this may cause problems federating with instances that only support IPv4, but this has yet to cause me a problem, and is far better than not being able to federate at all.