Creating and serving gemini capsules

What is Gemini?

Gemini is a new internet protocol which is different from the HTTP and Gopher. It's much cleaner.

Why use gemini protocol?

To access any gemini urls i.e. gemini://landchad.net, you can use any gemini client such as amfora, lagrange, elpher, etc.

Instructions

To create and serve a gemini capsule, we need three basic steps:

  1. Content
  2. TLS certificate
  3. Gemini server

We can create three different directories to simplify the process:

mkdir -p gemini/{content,certificate,server}

Content

Gemini uses text/gemini markup. It heavily borrows from Markdown. Similar to .html or .md, gemini uses .gmi as its extension.

To create one gemini file, go inside the content directory and create one index.gmi file.

touch gemini/content/index.gmi

Update the file content of index.gmi

# This is Sample Gemini page
## With header 1 and header 2
And a short paragraph like this.
=> /index.gmi Link to the same page

TLS certificate

Go to the certificate directory which we have created earlier. Generate the TLS certificate using OpenSSL. Change YOURDOMAIN.COM to the domain of your gemini capsule.

openssl req -new -subj "/CN=YOURDOMAIN.COM" -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -days 3650 -nodes -out cert.pem -keyout key.pem

Gemini server

There are many gemini servers available. You can check the list of servers here.

We will use agate server for now. This is a simple gemini server written in Rust. Go to server directory and download agate server.

wget https://github.com/mbrubeck/agate/releases/download/v3.1.0/agate.x86_64-unknown-linux-gnu.gz

Unzip the gz

gunzip agate.x86_64-unknown-linux-gnu.gz

Rename and make it executable

mv agate.x86_64-unknown-linux-gnu agate-server
chmod +x agate-server

Now we need to create a systemd service

sudo touch /etc/systemd/system/agate.service

Copy the below file and paste in agate.service.

[Unit]
Description=agate
After=network.target

[Service]
User=USER
Type=simple
ExecStart=/home/USER/gemini/agate-server --content /home/USER/gemini/content --certs /home/USER/gemini/certificate/ --hostname YOURDOMAIN.COM --lang en-US

[Install]
WantedBy=default.target

Now we are ready to run server. Enable and run agate server.

systemctl enable agate
systemctl start agate

Finalization

Now your server should be running. If everything went okay, you can access your gemini via any gemini client with this url

gemini://example.org

Sample gemini site for reference:

gemini://gemini.circumlunar.space

Enjoy your first gemini capsule.


Written by nihar.page