💾 Archived View for perplexing.space › 2022 › re-selfhosting-gemini.gmi captured on 2024-02-05 at 09:27:16. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2022-06-03)
-=-=-=-=-=-=-
2022-05-18
Another question!
What do people recommend for setting up one's own domain name and making Gemini content available via gemini://my.domain.name/log/stuff.gmi and not gemini://my.domain.name:98765/log/stuff.gmi
If I have understood the question correctly this has to do with handling well-known ports and the software that expects their defaults.
The reason the first example "works" for most gemini clients is due to the use of the standard port 1965. This is explained in the gemini specification:
When Gemini is served over TCP/IP, servers should listen on port 1965
The clients expect 1965 to be gemini:// so they don't require a port specification. If you use a non-standard port, like the second example, the clients have to ask for it specifically.
In order to respond to requests from clients for port 1965 (the default) _something_ has to be listening and either responding to requests or forwarding them on to another server like one running on port 65535 (ports don't go so high as 98765!). You can also imagine a similar scenario with multiple different servers on the same physical machine; maybe you want to run gemini servers for both foo.com and bar.com off the same machine but different gemini servers.
The requisite piece of technology is a _proxy_ to receive requests and delegate to the appropriate server. Here is the necessary configuration for a program called HAProxy to listen on port 1965 and pass requests to a server that is actually running on 1966.
listen gemini bind *:1965 mode tcp server gmnisrv 127.0.0.1:1966
Most proxies are hugely flexible, you can achieve a similar result with nginx, you can also do increasingly strange things - receive requests for port 1965 and forward them to another machine entirely, for example.
The only other part of the question that I understood might be a curiousity is the use of a subdomain. DNS records dictate how domains and subdomains are resolved, you can create an "A record" for the subdomain and it would look something like this:
my 3600 IN A 173.199.124.14
Where the first bit is the subdomain, the second is how long the record should be considered "good" for, the last is the IP address to which the name should resolve. Configurations can get more exotic through the use of "wildcards", so that _any_ subdomain is available without thinking of them ahead of time -- the idea is the same.
I have used freedns.afraid.org for dynamic DNS in the past, wherein my computer at home periodically calls out to afraid.org to update DNS records. It works like a charm and I only moved away from it when I started renting servers on the internet instead. They also provide free DNS but I haven't used it for much. I am a little tempted now that I'm looking again.