https://github.com/milouse/diamant
A simple Gemini server written in Ruby
https://github.com/milouse/diamant
gemini gemini-protocol gemini-server ruby
Last synced: 2 months ago
JSON representation
A simple Gemini server written in Ruby
- Host: GitHub
- URL: https://github.com/milouse/diamant
- Owner: milouse
- License: wtfpl
- Created: 2021-04-28T11:09:24.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-07-17T20:59:55.000Z (10 months ago)
- Last Synced: 2025-02-22T21:32:28.227Z (3 months ago)
- Topics: gemini, gemini-protocol, gemini-server, ruby
- Language: Ruby
- Homepage: https://git.umaneti.net/diamant/
- Size: 56.6 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
#+title: Diamant Gemini Server
#+subtitle: A simple Gemini server for static files.
#+author: Étienne Deparis
#+language: enDiamant is a server for the Gemini network protocol, built in ruby. Diamant
has very few features, and can only serve static files.[[gemini://gemini.circumlunar.space/][About the gemini protocol]]
[[https://gemini.circumlunar.space/][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 [[https://liberapay.com/milouse][Liberapay]] or [[https://paypal.me/milouse][Paypal]]. Thank you very much!* About the name
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.[[https://en.wikipedia.org/wiki/Diamant][About the Diamant rocket program on Wikipedia]]
* Installation and setup
Diamant is a [[https://rubygems.org/gems/diamant][ruby gem]]. You need a working ruby environment to use it. We
recommand you to use [[https://rvm.io][RVM]] and a specific gemset. However, it will work with a
global ruby installation too.#+caption: Installation procedure with RVM
#+begin_src shell
rvm get latest
rvm use ruby-2.7.2@diamant --create
gem install diamant
#+end_srcThen 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:
#+caption: TLS certificate and private key creation with Diamant
#+begin_src shell
diamant generate_tls_cert myhostname.com
#+end_srcYou can also use the OpenSSL command if you prefer:
#+caption: TLS certificate and private key creation with OpenSSL
#+begin_src shell
openssl req -x509 -newkey rsa:4096 -keyout key.rsa -out cert.pem
-days 3650 -nodes -subj "/CN=myhostname.com"
#+end_srcFinally, you should create a folder to store your static files to serve:
#+caption: Creation of the first Gemini files
#+begin_src shell
mkdir public_gmi
echo 'Hello World!' > public_gmi/index.gmi
#+end_src* Run the server
** Basic way
With all the default options, running the server is as simple as:
#+caption: Running Diamant with default options
#+begin_src shell
diamant
#+end_srcHowever, you may want to use some other options:
#+caption: Running Diamant with some other options
#+begin_src shell
diamant serve ~/my_gemini_site -b 0.0.0.0
#+end_srcTo see all possible options, just enter the following command:
#+caption: Access Diamant help
#+begin_src shell
diamant --help
#+end_src** As a systemd service
You can take inspiration from the following service example file:
#+caption: systemd service file example for Diamant
#+begin_src conf
[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
#+end_src* Sources
Development occurs on my own git repository:
[[https://git.umaneti.net/diamant/][Diamant gemini server git repository]]
[[./TODO.org][Diamant current backlog]]
* See also
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).[[https://github.com/rawburt/gack][Gack on github]]