etherai / selfhosted-gateway

Self-hosted Docker native tunneling to localhost. Expose local docker containers to the public Internet via a simple docker compose interface.
https://fractalnetworks.co
GNU Affero General Public License v3.0
1.32k stars 66 forks source link

Support subdomains, not just sub-subdomains #16

Closed TheFockinFury closed 1 year ago

TheFockinFury commented 1 year ago

I would love for selfhosted-gateway to support subdomains, not just sub-subdomains. For example, service.domain.tld as opposed to service.sub.domain.tld. In doing so, I could expose self-hosted services via .domain.tld as opposed to .sub.domain.tld.

There are a number of reasons this would be good, though admittedly a lot of it is cosmetic (shorter URLs for your exposed services). However, there's one use case in particular that I would position as the most important: Cloudflare doesn't let you proxy sub-subdomains without being on a subscription plan. If I want to use Cloudflare DNS to point service.sub.domain.tld to my gateway, I need to disable their 'proxy' feature, thereby exposing my gateway IP to the world.

As a Cloudflare DNS user, I'd like selfhosted-gateway to support FQDNs in the format of .domain.tld instead of .sub.domain.tld so that I can continue to use Cloudflare's 'proxy' feature and not expose my gateway IP without needing to pay $10/month for an advanced certificate.

xmxstudio commented 1 year ago

i second this. also setup fails to fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz halting the installer ;)

thrOo commented 1 year ago

I not a expert here but I've been using the gateway for about 3 months with various service on normal sub-domains. music.domain.tld points to my navidrome instance (gateway on vps, navidrome on rpi)

I would love for selfhosted-gateway to support subdomains, not just sub-subdomains.

Where did get that limitation from ?

TheFockinFury commented 1 year ago

Where did get that limitation from ?

Hmm, I had tried this with no success and @thebalaa mentioned it only worked with sub-subdomains. I’ll try again later as I could always be wrong but I was pretty sure it doesn’t work. What settings are you using? Thinking it could depend on whether you’re using FORWARD_ONLY for example, but what do I know.

TheFockinFury commented 1 year ago

Oops 👆

thrOo commented 1 year ago

I believe you are right, that it depends on the usage of FORWARD_ONLY. I don't use that. wasn't there when i set it up

make link GATEWAY=name@gateway.domain.tld FQDN=music.domain.tld EXPOSE=navidrome:1234

dkbnz commented 1 year ago

Currently using this for two separate services on two subdomains. Set both up using make link GATEWAY=... FQDN=abc.domain.tld EXPOSE=abc:1234. Not using FORWARD_ONLY mode.

thebalaa commented 1 year ago

Not related to FORWARD_ONLY.

Subdomains have always been supported, by default sub-subdomains of a subdomain would be forwarded along to the same endpoint as the subdomian.

I believe the original intent of this issue was to replicate the current subdomain behavior for TLD (top-level) domains such that a link for mydomian.com would also forward (SNI) traffic for *.mydomain.com to the same client link container endpoint.

If I am not mistaking @TheFockinFury main issue with the current subdomain support is that he would have to run 1 link container per subdomain whereas with the new functionality all subdomains for a TLD would be served by a single link.

We just started work on v2 of this project and plan to add support for this behavior. Let me know if I missed anything.

Thanks again for the feedback.