jamsocket/plane

Drone Proxy: Allow Custom Routes

t-moe opened this issue · 5 comments

t-moe commented

We're using plane in the standalone configuration (single drone, without dnsmasq / firefox).
We use a wilcard dns to map *.example.com => 1.2.3.4

In order to manage plane, we have a custom webservice. Currently we need a separate host or port for that, but we would like to host that on the same host and port as the drone.
For Example:

  • When we visit example.com we reach our custom webservice (e.g. listening on 127.0.0.1:4567)
  • When we visit e485cf9a-fc65-4d7c-935e-656572068226.example.com => we reach the launched backend

It would be nice if we could provide custom subdomain to route mapping in the drone.toml as a map.
Example:

[proxy]
# IP to listen for connections on.
bind_ip = "0.0.0.0"

[proxy.custom_route]
host = "status.example.com"
route = "http://127.0.0.1:9874"

[proxy.custom_route]
host = "example.com"
route = "http://127.0.0.1:4567"

If I'm correct, I could extend the code here, to make that work:
https://github.com/drifting-in-space/plane/blob/dbd550e9b1db33e611ab00730182a28eaf12e7db/drone/src/proxy/service.rs#L203-L236

I understand the use case here but I'm a little cautious about adding a feature that only makes sense in a single-drone context.

One possibility would be to allow a "fallback" address that anything that is not a current backend is proxied to. In a multi-drone context this would provide a way to display a custom page when an invalid domain is accessed. In your case, it could point to a local nginx/caddy/whatever server which could serve from different directories depending on the hostname.

t-moe commented

I see your point.
Yes, a single "fallback" address would be enough. At the moment we only need a single custom route anyways and if we need more later we can still fire up a local nginx (as you said).

Gotcha, this should be do-able then. I should be able to do this over the next couple of days, but if you want to take it on I'd also accept a PR.

My preference would be for this to be a single string like this:

[proxy]
bind_ip = "0.0.0.0"
fallback_addr = "12.12.12.12:8080"

(i.e. no http://)

t-moe commented

This works like a charm.

Paul, Thank you so much for the fast support and for adding the custom features I've requested. 🙌

Glad it works, thanks for following up!