omar-polo / gmid

a Gemini server
https://gmid.omarpolo.com
ISC License
98 stars 8 forks source link

proxy to nex protocol? #27

Closed d47081 closed 2 months ago

d47081 commented 2 months ago

Hello, can I setup the upstream located at nex protocol?

omar-polo commented 2 months ago

I don't know the nex protocol, so probably not. The proxy facility only supports gemini and gemini-without-tls (which is not a proper protocol but in practice it can be useful.)

Can you share a link to a page describing the protocol?

Thanks!

d47081 commented 2 months ago

It is same protocol to Gopher/Gemini, but without redirects, status codes, and other meta.

It also does not require domain / TLS / SNI so pretty useful for encrypted alt networks like yggdrasil, where addressation usually just 0200::/7 and certificate is extra-layer for traffic that already encrypted.

For example I run every my service on yggdrasil servers (in localnet) and proxy to internet using gmid.

I must to make cert for each instance, even cert wanted just for gmid proxy outpoint.

Protocol details here:

I have few solutions already written in PHP

Nex also supported by Lagrange browser so don't think this protocol is rare and pretty new

omar-polo commented 2 months ago

Oh, interesting. This protocol went under my radar :)

Upon a quick look it seems like adding support for it will be very easy (easier than #23 for sure :p). I just have a few doubts/questions open:

d47081 commented 2 months ago

I'm still learning this protocol by development those solutions.

As understand:

omar-polo commented 2 months ago

Ah I see. Maybe we can even re-use gmid' built-in mime types for this.

d47081 commented 2 months ago

Thoughts make same for next server, but how to make browser know that is gemtext without the headers?

The client-side only - default mime option or the markup detection, no server-side way :)

d47081 commented 2 months ago

Thought, if you just make gmid able to pass the nex responses as is, there would be no problem with gemtext interpretation, because proxy has gemini:// at the protocol scheme.

Just pass the raw data with required for gemini protocol headers, maybe as the config option.

btw, still dream about same feature for #23

d47081 commented 2 months ago

I also don't understand subject with / at the address ending.

Maybe protocol author is just Windows user where directories and files with same name possible to store in same location

d47081 commented 2 months ago

Found that nginx able to forward both NEX/NPS connections as TCP stream:

# /etc/nginx/nginx.conf

stream {
        server {
                listen 1915;
                proxy_pass 127.0.0.1:1915;
        }
}

https://github.com/kevachat/npsapp#nginx

omar-polo commented 2 months ago

Yeah, if the intention is to just forward the connection to a specific backend then a dedicated daemon like relayd, haproxy or even nginx is probably better.

I don't think it would be a good move for gmid to become capable of proxy random data, it's not designed for that. There are better options for that.

What I think could be worthwhile, although i'm still a bit undecided, if it could make sense to use gmid to proxy/convert other protocols to gemini. So that it can be used to make available nex:// pages from gemini://, or like proposed in #23 to fetch content via http and serve it via gemini.