Diamant is a server for the Gemini network protocol, built in ruby. Diamant has very few features, and can only serve static files.
About the gemini protocol About the gemini protocol
Internally, it uses the OpenSSL library to handle the TLS sessions, and the
ruby Thread
implementation to handle concurrent requests.
If you like my work, you can help me a lot by giving me a tip, either through Liberapay or Paypal. Thank you very much!
It is named « Diamant », in reference to one of the first French attempts to build a rocket. The first Diamant launch happened in 1965, exactly like Gemini. I think it’s cool.
About the Diamant rocket program on Wikipedia
Diamant is a ruby gem. You need a working ruby environment to use it. We recommand you to use RVM and a specific gemset. However, it will work with a global ruby installation too.
rvm get latest
rvm use ruby-2.7.2@diamant --create
gem install diamant
Then you need to generate a self-signed TLS certificate and private key. In
the following example, remember to replace the example hostname
myhostname.com
with the one you would like to use.
Diamant provides a tool to create these certificates and keys:
diamant generate_tls_cert myhostname.com
You can also use the OpenSSL command if you prefer:
openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem
-days 3650 -nodes -subj "/CN=myhostname.com"
Finally, you should create a folder to store your static files to serve:
mkdir public_gmi
echo 'Hello World!' > public_gmi/index.gmi
With all the default options, running the server is as simple as:
diamant
However, you may want to use some other options:
diamant serve ~/my_gemini_site -b 0.0.0.0
To see all possible options, just enter the following command:
diamant --help
You can take inspiration from the following service example file:
[Unit]
Description=Control Diamant Gemini Server
After=network.target
[Service]
Type=simple
User=gemini
Group=gemini
Environment="PATH=/home/gemini/.rvm/gems/ruby-2.7.2@diamant/bin:/home/gemini/.rvm/gems/ruby-2.7.2@global/bin:/home/gemini/.rvm/rubies/ruby-2.7.2/bin:/home/gemini/.rvm/bin:/usr/local/bin:/usr/bin:/bin"
Environment="GEM_HOME=/home/gemini/.rvm/gems/ruby-2.7.2@diamant"
Environment="GEM_PATH=/home/gemini/.rvm/gems/ruby-2.7.2@diamant:/home/gemini/.rvm/gems/ruby-2.7.2@global"
WorkingDirectory=/home/gemini
ExecStart=/home/gemini/.rvm/gems/ruby-2.7.2@diamant/bin/diamant -b 0.0.0.0
KillMode=control-group
[Install]
WantedBy=multi-user.target
Development occurs on my own git repository:
Diamant gemini server git repository
Be aware that another ruby implementation exists, named Gack. Diamant differs from it for two reasons:
- it directly support TLS. There is no need to put it behind a reverse proxy, just run it (even as a simple user, as the 1965 port is not a protected one).
- it will only serve static content from a given repository, when Gack is more like an application framework (it is named after Rack).