overseerr icon indicating copy to clipboard operation
overseerr copied to clipboard

Run overseerr on subpath, Base URL

Open mmozeiko opened this issue 5 years ago • 64 comments

Is your feature request related to a problem? Please describe. I'm reverse-proxying all services on main domain with caddy. Like https://example.com/radarr/ and https://example.com/sonarr/ and I want to do same with https://example.com/overseerr/ But currently it expects to be available on / path.

Describe the solution you'd like Solution would be either to use relative URL's throughout the project. Or allow to specify base url/path in startup parameters, like PORT is specific in env variables. Like export BASE=/overseerr would be good enough for me.

mmozeiko avatar Dec 14 '20 20:12 mmozeiko

Have to agree with this, it's really only usable for me to tinker with once in awhile. Can't have any other users try it out without letting it through the proxy.

adamskoog avatar Dec 28 '20 14:12 adamskoog

Have to agree with this, it's really only usable for me to tinker with once in awhile. Can't have any other users try it out without letting it through the proxy.

You could always run it through a proxy on a subdomain, if your setup permits.

Subpath will take some time to figure out. Might be awhile :(

sct avatar Dec 28 '20 16:12 sct

I'd love to make this work as well

jluis2k10 avatar Dec 28 '20 20:12 jluis2k10

Have to agree with this, it's really only usable for me to tinker with once in awhile. Can't have any other users try it out without letting it through the proxy.

You could always run it through a proxy on a subdomain, if your setup permits.

Subpath will take some time to figure out. Might be awhile :(

Kind of a bummer, I don't currently have the option to do a subdomain without a bit of work. Not in the cards at the moment. Look forward to where this goes though.

adamskoog avatar Dec 28 '20 23:12 adamskoog

Isn't this just a matter of setting the baseurl in next config and doing namespace in express? Can you elaborate on what is hindering this @sct ?

ankarhem avatar Jan 04 '21 23:01 ankarhem

iirc next does not really support setting dynamic baseurls in runtime, so it would be have to built with it already set.

flying-sausages avatar Jan 04 '21 23:01 flying-sausages

Oh, yeah that's true. So the solution for us would be to prepend every use we have of express, links etc with an env variable we can pass in to the docker image for instance?

ankarhem avatar Jan 04 '21 23:01 ankarhem

Sounds a little hacky, unless you have something centralized that would generate links already. I didn't check your codebase yet.

I'd personally settle with setting it at build-time, it's not often you will change this i feel.

flying-sausages avatar Jan 04 '21 23:01 flying-sausages

Changing base path in next.config.js is only part of solution. It works and makes app to listen on correct base path (this is a build time setting). I've tried it and it works. But you need to change also all XHR requests in frontend from /api to $base/api. This involves all calls to axios.get/post and useSWR in frontend code.

I was planning to do this, but was busy past few weeks finishing #538. My plan was to have build setting in some config file that gets used in both frontend and server. That would be good enough for my usage. Doing this as runtime settings would be much much more work to figure out how to do it.

But if somebody is doing this, then let me know and I won't look at this.

mmozeiko avatar Jan 05 '21 00:01 mmozeiko

But if somebody is doing this, then let me know and I won't look at this.

Looks like no one is ha

flying-sausages avatar Jan 09 '21 18:01 flying-sausages

As far as I understand it, setting the base url at build time doesn't work super well with Docker because generally a base url change will require the frontend to be recompiled, which means that you'd either have to

  • do frontend compilation as part of the container entry point (at runtime), or
  • require that anybody changing their base url builds their own docker container.

Neither is very appealing in the long run, though they're both far better in the short term than not being able to use the app at all (for many of our use-cases).

To be able to set the base url at runtime, you'd need a couple things:

  • to be able to serve up the static files (js bundles, index.html, images, etc.) from a dynamic base url at runtime (server restart would be fine). In a normal non-SSR app this would be pretty easy, not sure how it changes with Next.

  • to know, in frontend code, what base url it's currently being served from (to prefix api calls).

  • Maybe next could dynamically hydrate the frontend with the base url that it's serving it from somehow? Not sure how that would affect asset paths like images and such, but it would make api call prefixing pretty simple.

mmgoodnow avatar Jan 21 '21 05:01 mmgoodnow

I have all my apps setup using subfolders, I can't really use this without suborder reverse proxy, as I already have my home server on a subdomain.

RageInvader avatar Feb 01 '21 00:02 RageInvader

All,

There is an unsupported workaround in the overseerr docs. Please use it at your own risk! This could break at any point. No support will be given for this workaround.

If you are having issues please verify that it is reproducible when accessing overseerr directly!

https://docs.overseerr.dev/extending-overseerr/reverse-proxy-examples#nginx

samwiseg0 avatar Mar 08 '21 00:03 samwiseg0

And to be clear, we are still looking into building this support into Overseerr directly. But ETA for that is still unknown.

sct avatar Mar 08 '21 00:03 sct

Any chance this is going to be looked at again? I notice that it's been removed from the roadmap.

/b

brettpetch avatar Apr 26 '21 21:04 brettpetch

@brettpetch Please see the comment right above yours. https://github.com/sct/overseerr/issues/274#issuecomment-792391378. Please do not post in issues asking for status updates. We are diligent in updating issues as things change. We provide no ETAs.

samwiseg0 avatar Apr 26 '21 21:04 samwiseg0

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 25 '21 21:06 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 25 '21 16:08 stale[bot]

Hide this comment pls

flying-sausages avatar Aug 25 '21 18:08 flying-sausages

Would really love this feature and am willing to contribute.

I've implemented this feature in my private repo (see PR: https://github.com/ElMoselYEE/overseerr/pull/1) but it only works when using build-time variables; I'm hitting a blocker with how to achieve this at runtime. @mmgoodnow your comments about dynamic frontend hydration seem promising although I'm not really sure how to implement such a workflow.

ElMoselYEE avatar Sep 28 '21 14:09 ElMoselYEE

@ElMoselYEE Feel free to join us on Discord to discuss!

TheCatLady avatar Sep 28 '21 15:09 TheCatLady

The lack of this feature is preventing Overseerr from being made available to many Plex VPS providers. Screen Shot 2021-11-04 at 21 56 52

anonyme123 avatar Nov 04 '21 20:11 anonyme123

Would really love this feature and am willing to contribute.

I've implemented this feature in my private repo (see PR: ElMoselYEE#1) but it only works when using build-time variables; I'm hitting a blocker with how to achieve this at runtime. @mmgoodnow your comments about dynamic frontend hydration seem promising although I'm not really sure how to implement such a workflow.

I also would really love this feature. I hope you dont mind but i am taking a swing at making this configurable without needing a rebuild.

megamit avatar Jan 01 '22 21:01 megamit

Oh, I forgot to ever reply to this. I was sort of picturing a situation where, when index.html is requested, you read the file and splice a script tag into it:

<script>
    window.baseUrl = ${process.env.BASE_URL}
</script>

Then after that interpolation you can send it off to the client who can read from that window var.

mmgoodnow avatar Jan 01 '22 21:01 mmgoodnow

Yep that's essentially what i have done except instead of using a global script it is using Runtime Configuration

megamit avatar Jan 01 '22 21:01 megamit

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Mar 03 '22 22:03 stale[bot]

I did this with my app I've been working on (not Next, just React) - not sure if it would help you figure something out: https://www.freecodecamp.org/news/how-to-implement-runtime-environment-variables-with-create-react-app-docker-and-nginx-7f9d42a91d70/

This would be the full implementation for what @mmgoodnow posted above.

adamskoog avatar Mar 13 '22 17:03 adamskoog

For the moment this Workaround using nginx is still valid: https://github.com/sct/overseerr/pull/1114

rix1337 avatar Apr 10 '22 10:04 rix1337

In case anyone is interested for a way to do this with Traefik, I've got it working with the following:

Setup a supplemental nginx container called overseerr-web that uses the setup from the documentation for a subpath (#1114

Then gave it the following labels

labels:
      traefik.docker.network: 'web'
      traefik.enable: 'true'
      traefik.http.routers.overseerr-web.entrypoints: 'websecure'
      traefik.http.routers.overseerr-web.rule: 'Host(`media.example.net`) && PathPrefix(`/overseerr`)'
      traefik.http.routers.overseerr-web.service: 'overseerr-web'
      traefik.http.services.overseerr-web.loadbalancer.server.port: '80'
      # Fix trailing slash
      traefik.http.middlewares.strip-prefix.chain.middlewares: 'strip-prefix-1,strip-prefix-2'
      traefik.http.middlewares.strip-prefix-1.redirectregex.regex: '^(https?://[^/]+/[a-z0-9_]+)$$'
      traefik.http.middlewares.strip-prefix-1.redirectregex.replacement: '$${1}/'
      traefik.http.middlewares.strip-prefix-1.redirectregex.permanent: 'true'
      traefik.http.middlewares.strip-prefix-2.stripprefixregex.regex: '/[a-z0-9_]+'

Of course I've sanitized some labels, but this is currently working for me. I am personally using the PathPrefix "/request" and have adjusted the nginx file accordingly.

Hope this helps someone.

joeknock90 avatar Apr 14 '22 23:04 joeknock90

I see all these mentions of people implementing hacks etc. I notice on the docker site, there are versions by different authors available. Anyone know if there's a hack for Apache or another docker version that does offer this? I really need it.

SteffanCline avatar Apr 24 '22 07:04 SteffanCline