danvergara / morphos

Self-hosted file converter server
MIT License
750 stars 33 forks source link

Allow setting a Path for the Web-Interface #52

Closed CC3301 closed 1 month ago

CC3301 commented 2 months ago

Is your feature request related to a problem? Please describe. I was trying to get this to work behind a PathPrefix, which i wasn't successful with. I am using a single subdomain for a few small tools, which live under different paths. This is to avoid Let's Encrypt Rate-Limits.

Describe the solution you'd like I'd suggest to make a Path configurable via Environment-Variables, which would integrate nicely with docker.

Describe alternatives you've considered I tried adjusting and playing around with my Traefik-Configuration, but i was unable to make it work.

Additional context Morphos is hosted under a subdomain, among other services. e.g. "tools.example.com" and requests are routed via paths: "tools.example.com/morphos". Unfortunately i am not very good with go, otherwise i could make a suggestion on how to implement such a thing.

danvergara commented 1 month ago

Hi @CC3301, Thanks for reaching out and for using the tool! Regarding your issue, Morphos is designed to be agnostic of its hosting environment, meaning it doesn’t make any assumptions about how it’s hosted or configured. This approach helps keep it flexible and widely usable. From what you’ve described, it seems like the challenge lies more in the configuration of your Traefik setup rather than something specific to Morphos. Given that, I’d recommend opening a support issue with the Traefik team, as they would have more targeted advice for your specific scenario. However, I can suggest a potential workaround that might help you resolve the problem. When configuring Traefik, you can use the PathPrefix middleware to correctly route requests to the appropriate services. Here’s a basic example of how you might configure this in your traefik.yml:

http:
  routers:
    morphos:
      rule: "Host(`tools.example.com`) && PathPrefix(`/morphos`)"
      service: morphos-service

  services:
    morphos-service:
      loadBalancer:
        servers:
          - url: "[http://morphos:80](http://morphos/)"
CC3301 commented 1 month ago

Thank you for your response and explanation! I had a trailing / in the PathPrefix-Rule, could that have been the cause? Regardless, seems like it's working now. Cheers :)

danvergara commented 1 month ago

@CC3301 Glad to know that!

Let me close this issue, then.