Deploying my own Gemini capsule with gmnisrv

Wednesday, February 10, 2021

selfhostinggeminigmnisrv

I’ve been following Gemini for a bit of time and as I liked the concept and I love to play with new things, I decided to launch my own gemini capsule (aka, my own “site” on the gemini “web”).

You can access it here: gemini://gmi.bacardi55.io

Disclaimer: The result is not perfect yet. For now I’ve only put my blog posts but internal links to other content or images do not fully work yet but I’ll fix this later.

I do plan to create specific content on gmi at some point, for things that are not really “blog post” material but still worth typing for my future self :D.

I’d like to highlight and thanks some posts that convince me of doing it:

And others that I’ve seen in my RSS feeds or on mastodon :).

Gemini you say ?

For those that don’t know, as said on the gemini website:

Gemini is a new, collaboratively designed internet protocol, which explores the space inbetween gopher and the web, striving to address (perceived) limitations of one while avoiding the (undeniable) pitfalls of the other.

I suggest you read more about it on the FAQ page that contains all the necessary informations :).

Gemini server setup

I was looking for an extra lightweight server and trying to avoid Go or Rust for server part. In the end, I I selected gmnisrv, developed by Drew Devault in C. Easy to install, self manage certificate and very light to run on an old raspberry pi.

Installation

You should already have openssl installed, but if not, install it with your packet manager.

Also, on the project page it says that scdoc is optional, but I couldn’t install without it, so I ended up installing it too.

To install scdoc:

git clone https://git.sr.ht/~sircmpwn/scdoc
cd scdoc
make
sudo make install

Then, to install gmnisrv:

git clone https://git.sr.ht/~sircmpwn/gmnisrv
cd gmnisrv
mkdir build
cd build
../configure --prefix=/usr
make
sudo make install

Configuring the server

Copy the default config file at the right place:

cp /usr/share/gmnisrv/gmnisrv.ini /etc/gmnisrv.ini

And edit it as needed for the certificate path and the files path.

I use /srv/gemini/gmi.bacardi55.io as the path where my *.gmi files will be.

For now, let’s create a default hellowolrd page:

echo "hellowolrd55!" > /srv/gemini/gmi.bacardi55.io/index.gmi

Creating a systemd service

To automate the (re)start of the server, I created a systemd service. To do so, I created /etc/systemd/system/gmnisrv.service with the following content:

[Unit]
Description=Gemini Server gminisrv
After=network.target

[Service]
Type=simple
# Another Type: forking
User=gemini
ExecStart=/usr/bin/gmnisrv
Restart=always

[Install]
WantedBy=multi-user.target

As you can see, I use a dedicated gemini user on my system to run it as a limited users.

Then, enable the service and then start it:

sudo systemctl enable gmnisrv
sudo systemctl start gmnisrv

Remember also that it uses port 1965, so if you selfhost at home, don’t forget to open the port and redirect flow on this port on the right server.

To test locally first, edit your /etc/hosts to map the domain config in the server file and the IP of the server in a gemini client.

You can find a list of clients on this page. On my side, I used gmni but any client will do.

To test it works from the outside, either install a cli/tui client on an external server or test it via an online portal like this one.

And voilà, you should see your hellowolrd page :)

In the next post, I talk about how I use my blog generator Hugo to generate both this blog and the gemini pages.


Contact

If you find any issue or have any question about this article, feel free to reach out to me via email, mastodon or even IRC, see the About Me page for details.

See Also

Managing this site and my gemini capsule with Hugo

Home Automation, part 4: List of my NodeRed automation flows