How to make a Gemini capsule and website with Agate and Kineto

This is a new post about making a gemini capsule, but this time with other technologies.

Here you can find my old one where I used titan2 instead

Creating a Gemini capsule

To create a gemini capsule you just need to start by creating an "index.gmi" file in a directory

mkdir gemini
echo "# Hello world" >> gemini/index.gmi

To organise your capsule you can then create subdirectories for the different categories, and for each category create another index file.

You can also create a feed.xml file with an atom feed in it (either Atom or RSS) that people can subscribe to. By adding things in it, you can notify them of your new posts.

Everytime you want to add a new post, you can create a new file in the right subdirectory (or create the directory), then add a link to that file in the right index file and in the feed (if you want people to be notified).

Then you need to send your stuff over to a server. For this you can for example use rsync.

rsync -rv ~/gemini/ <username>@<host>:/<path to location>

In my case I also use Git to manage my Gemini capsule. So I've added that command into a pre-push Git hook. So every time I do a Git push, my changes are pushed both on Git and my Gemini server.

You might also appreciate lazygit to interact easily with Git repositories

Serving the Gemini content

Then you need to install Agate. In some cases you can install it from your package manager (such as on NixOS or Arch Linux). Otherwise, you can also install it from the pre-compiled binary or compiling it yourself with cargo. Make sure this is installed on the server.

Agate's home page on Gemini

Agate's home and download page on the web

Finally, we can connect to the server and setup the thing. Since I'm lazy I'm just going to run it in background mode without actually creating a service. Note however that making a service would be a lot cleaner.

ssh <username>@<host>
nohup agate --hostname <your hostname> --content <path to your content directory> &

The "nohup" command will redirect the output of the command into a logging file and will prevent the server from closing from logout. The & symbol at the end will run the command in the background.

Once the server is running, we can make sure the firewall allows the access to the port 1965 (the gemini port).

sudo ufw allow 1965/tcp

Serving Gemini over HTTP (proxy using Kineto)

Since I want to be able to share my content with people who don't use Gemini, I'm going to mirror my gemini capsule on HTTP. This can be done with the Kineto proxy, which is for example used for the official geminiprotocol.net website

See an example of Kineto running on the official Gemini website

Finally we can install Kineto. First you have to make sure Go is installed.

Golang's download page

git clone https://git.sr.ht/~sircmpwn/kineto
cd kineto
go build

Then you can then run the proxy

nohup ./kineto -b 127.0.0.1:8080 gemini://<your hostname> & 

Then you can setup your reverse proxy to then point and secure the connection to your Kineto proxy. In my case with Caddy, I simply had to add this to the Caddyfile:

your.domain.name {
	reverse_proxy: 8080
}

Then you can reload the reverse proxy

caddy reload