bugfest / tor-controller

Tor toolkit for Kubernetes (Tor instances, onion services and more)
Apache License 2.0
98 stars 17 forks source link

is it possible to have multiple services filtered by spec.rules.path #62

Closed ceddybi closed 9 months ago

ceddybi commented 9 months ago

Describe the bug

Instead of target by port

rules:
    - port:

we target host/path without using external web server (nginx)

rules:
    - path: /cdn
       backend:
        service:
          name: cdn-service
    - path: /api
       backend:
        service:
          name: api-service
bugfest commented 9 months ago

Hi @ceddybi,

The OnionService CRD is used to render a torrc file so that the tor daemon can route onion requests to the proper hidden service "backend". As the tor daemon only cares about routing, and does not interpret the protocol running ontop, so it won't be able to interpret the path (https://manpages.debian.org/testing/tor/torrc.5.en.html#HIDDEN_SERVICE_OPTIONS). To implement this feature we'd have to implement a reverse proxy (either from scratch or embedding an existing one; like the one you mention, nginx).

I would like to avoid that due to a number of reasons:

You can achieve such behavior following the ingress example: https://github.com/bugfest/tor-controller/blob/d0f977fda6baa18df2c3294ce9f72a6412960794/hack/sample/full-example.yaml#L55-L62 - please try this method and let me know if that'd solve your case.

Additional note

If you don't want to expose the service to the public IP space of your cluster so can deploy your ingress controller so that it uses clusterip: e.g. for nginx ingress controller you could set controller.service.type to clusterip: https://github.com/kubernetes/ingress-nginx/blob/6107346590f1f7e64749e0977deb4f639e145a17/charts/ingress-nginx/README.md?plain=1#L432

br/BF

ceddybi commented 9 months ago

thank you @bugfest, i ended up using multiple backends using different ports,

the problem was, having multiple services/domains, e.g one for cdn, api and another for frontend (3 in total), made the site very slow.

but with all 3 backends on one domain using different ports worked.