sct / overseerr

Request management and media discovery tool for the Plex ecosystem
https://overseerr.dev
MIT License
3.93k stars 450 forks source link

Run overseerr on subpath, Base URL #274

Open mmozeiko opened 3 years ago

mmozeiko commented 3 years ago

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.

adamskoog commented 3 years ago

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.

sct commented 3 years ago

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 :(

jluis2k10 commented 3 years ago

I'd love to make this work as well

adamskoog commented 3 years ago

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.

ankarhem commented 3 years ago

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 ?

flying-sausages commented 3 years ago

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

ankarhem commented 3 years ago

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?

flying-sausages commented 3 years ago

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.

mmozeiko commented 3 years ago

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.

flying-sausages commented 3 years ago

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

Looks like no one is ha

mmgoodnow commented 3 years ago

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

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:

RageInvader commented 3 years ago

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.

samwiseg0 commented 3 years ago

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

sct commented 3 years ago

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

brettpetch commented 3 years ago

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

/b

samwiseg0 commented 3 years ago

@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.

stale[bot] commented 3 years ago

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] commented 3 years ago

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.

flying-sausages commented 3 years ago

Hide this comment pls

ElMoselYEE commented 3 years ago

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.

TheCatLady commented 3 years ago

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

anonyme123 commented 3 years ago

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
megamit commented 2 years ago

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.

mmgoodnow commented 2 years ago

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.

megamit commented 2 years ago

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

stale[bot] commented 2 years ago

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.

adamskoog commented 2 years ago

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.

rix1337 commented 2 years ago

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

joeknock90 commented 2 years ago

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.

SteffanCline commented 2 years ago

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.

caio1007 commented 2 years ago

hi ,I installed the overseerr subfolder (https://docs.overseerr.dev/extending-overseerr/reverse-proxy) and it's giving this error, I use overseerr installed via docker on a raspberry pi 4 with dietpi system...>>>>

sudo service nginx restart Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.

sudo nginx -t nginx: [emerg] unknown directive "sub_filter_once" in /etc/nginx/sites-dietpi/over.conf:15 nginx: configuration file /etc/nginx/nginx.conf test failed

stale[bot] commented 2 years ago

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.

dansmith01 commented 2 years ago

Chiming in to clear the stale tag. This would be a really helpful feature!

dwk001 commented 2 years ago

I will be happy to pay to have this feature implemented

Thanks,

Dennis Kidwell

On Fri, Sep 9, 2022, 12:49 PM Daniel Smith @.***> wrote:

Chiming in to clear the stale tag. This would be a really helpful feature!

— Reply to this email directly, view it on GitHub https://github.com/sct/overseerr/issues/274#issuecomment-1242217015, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTN6LYBGJVKA6QERHGO22LV5NTADANCNFSM4U3KEGFQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

SteffanCline commented 2 years ago

I too would be willing to pay for this feature. I trust it's not a walk in the park the definitely feasible given the number of other *rr services that do this already.

dwk001 commented 2 years ago

I'll do $50 right now.

Thanks,

Dennis Kidwell

On Fri, Sep 9, 2022, 2:51 PM Steffan Cline @.***> wrote:

I too would be willing to pay for this feature. I trust it's not a walk in the park the definitely feasible given the number of other *rr services that do this already.

— Reply to this email directly, view it on GitHub https://github.com/sct/overseerr/issues/274#issuecomment-1242348414, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTN6L4RHFH3GAW5CTLULL3V5OBJ3ANCNFSM4U3KEGFQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

ftc2 commented 2 years ago

@ElMoselYEE wrote:

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

your fork is gone :( does anyone else have this working somewhere before i try to figure it out myself?

@mmozeiko wrote:

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.

harb88 commented 2 years ago

Unfortunately with version 1.30.0 of Overseerr the workaround in the documentation for this has broken: https://docs.overseerr.dev/extending-overseerr/reverse-proxy

I had to revert back to 1.29.1 to get it working again.

sct commented 2 years ago

Unfortunately with version 1.30.0 of Overseerr the workaround in the documentation for this has broken: https://docs.overseerr.dev/extending-overseerr/reverse-proxy

I had to revert back to 1.29.1 to get it working again.

There is already a fix. Check out the support channel in our discord.

markus-li commented 2 years ago

When testing this with subfolders I noticed that the currently suggested sub_filter rules left certain parts broken, such as if you refreshed the page it wouldn't work since the URL wouldn't be correct. It works when clicking around, but a refresh would break. "sw.js" and "offline.html" were also missing.

In case someone else is interested, this is what I came up with for nginx:

location ^~ /pods/direct/overseerr {
    set $app 'pods/direct/overseerr';
    set $app_esc 'pods\/direct\/overseerr';

    # Remove /pods/direct/overseerr path to pass to the app
    rewrite ^/pods/direct/overseerr/?(.*)$ /$1 break;
    proxy_pass http://127.0.0.1:5055; # NO TRAILING SLASH

    # Redirect location headers
    proxy_redirect ^ /$app;
    proxy_redirect /setup /$app/setup;
    proxy_redirect /login /$app/login;

    # Sub filters to replace hardcoded paths
    proxy_set_header Accept-Encoding "";
    sub_filter_once off;
    sub_filter_types *;

    # HREF
    sub_filter 'href="/"' 'href="/$app/"';
    sub_filter 'href="/login"' 'href="/$app/login"';
    sub_filter 'href:"/"' 'href:"/$app/"'; 

    ## Capture some things which shouldn't change
    sub_filter '.id,"/' '.id,"/';
    sub_filter '"/settings/main' '"/settings/main';
    sub_filter '"/settings/password' '"/settings/password';
    sub_filter '"/settings/permissions' '"/settings/permissions';
    sub_filter '"/settings/notifications' '"/settings/notifications';

    ## Now the remaining settings paths are ok to change
    sub_filter '"/settings' '"/$app/settings';

    ## Default filters:
    sub_filter '\/_next' '\/$app_esc\/_next';
    sub_filter '/_next' '/$app/_next';
    sub_filter '/api/v1' '/$app/api/v1';
    sub_filter '/login/plex/loading' '/$app/login/plex/loading';
    sub_filter '/images/' '/$app/images/';

    ## Route-specific filters:
    sub_filter '"/sw.js"' '"/$app/sw.js"';
    sub_filter '"/offline.html' '"/$app/offline.html';
    sub_filter '"/android-' '"/$app/android-';
    sub_filter '"/apple-' '"/$app/apple-';
    sub_filter '"/favicon' '"/$app/favicon';
    sub_filter '"/logo_' '"/$app/logo_';
    sub_filter '"/profile' '"/$app/profile';
    sub_filter '"/users' '"/$app/users';
    sub_filter '"/movie' '"/$app/movie';
    sub_filter '"/tv' '"/$app/tv';
    sub_filter '"/person' '"/$app/person';
    sub_filter '"/collection' '"/$app/collection';
    sub_filter '"/discover' '"/$app/discover';
    sub_filter '"/requests' '"/$app/requests';
    sub_filter '"/issues' '"/$app/issues';
    sub_filter '"/site.webmanifest' '"./site.webmanifest';
    # Setting settings paths so that they don't match the generic replace
    sub_filter 'route:"/settings/main' 'route:"/settings/main';
    sub_filter 'regex:/^\/settings\/main' 'regex:/^\/settings\/main';
    sub_filter 'route:"/settings/password' 'route:"/settings/password';
    sub_filter 'regex:/^\/settings\/password' 'regex:/^\/settings\/password';
    sub_filter 'route:"/settings/permissions' 'route:"/settings/permissions';
    sub_filter 'regex:/^\/settings\/permissions' 'regex:/^\/settings\/permissions';
    sub_filter 'route:"/settings/notifications' 'route:"/settings/notifications';
    sub_filter 'regex:/^\/settings\/notifications' 'regex:/^\/settings\/notifications';
    # Generic route and regex replace
    sub_filter 'route:"/' 'route:"/$app/';
    sub_filter 'regex:/^\/' 'regex:/^\/$app_esc\/';
    sub_filter 'regex:/\/' 'regex:/\/$app_esc\/';
}
SteffanCline commented 2 years ago

Sure would be nice to have this for Apache too!On Oct 11, 2022, at 12:42 AM, Markus Liljergren @.***> wrote: When testing this with subfolders I noticed that the currently suggested sub_filter rules left certain parts broken, such as if you refreshed the page it wouldn't work since the URL wouldn't be correct. It works when clicking around, but a refresh would break. "sw.js" and "offline.html" were also missing. In case someone else is interested, this is what I came up with for nginx: location ^~ /pods/direct/overseerr { set $app 'pods/direct/overseerr'; set $app_esc 'pods\/direct\/overseerr';

# Remove /pods/direct/overseerr path to pass to the app
rewrite ^/pods/direct/overseerr/?(.*)$ /$1 break;
proxy_pass http://127.0.0.1:5055; # NO TRAILING SLASH

# Redirect location headers
proxy_redirect ^ /$app;
proxy_redirect /setup /$app/setup;
proxy_redirect /login /$app/login;

# Sub filters to replace hardcoded paths
proxy_set_header Accept-Encoding "";
sub_filter_once off;
sub_filter_types *;

# HREF
sub_filter 'href="/"' 'href="/$app/"';
sub_filter 'href="/login"' 'href="/$app/login"';
sub_filter 'href:"/"' 'href:"/$app/"'; 

## Capture some things which shouldn't change
sub_filter '.id,"/' '.id,"/';
sub_filter '"/settings/main' '"/settings/main';
sub_filter '"/settings/password' '"/settings/password';
sub_filter '"/settings/permissions' '"/settings/permissions';
sub_filter '"/settings/notifications' '"/settings/notifications';

## Now the remaining settings paths are ok to change
sub_filter '"/settings' '"/$app/settings';

## Default filters:
sub_filter '\/_next' '\/$app_esc\/_next';
sub_filter '/_next' '/$app/_next';
sub_filter '/api/v1' '/$app/api/v1';
sub_filter '/login/plex/loading' '/$app/login/plex/loading';
sub_filter '/images/' '/$app/images/';

## Route-specific filters:
sub_filter '"/sw.js"' '"/$app/sw.js"';
sub_filter '"/offline.html' '"/$app/offline.html';
sub_filter '"/android-' '"/$app/android-';
sub_filter '"/apple-' '"/$app/apple-';
sub_filter '"/favicon' '"/$app/favicon';
sub_filter '"/logo_' '"/$app/logo_';
sub_filter '"/profile' '"/$app/profile';
sub_filter '"/users' '"/$app/users';
sub_filter '"/movie' '"/$app/movie';
sub_filter '"/tv' '"/$app/tv';
sub_filter '"/person' '"/$app/person';
sub_filter '"/collection' '"/$app/collection';
sub_filter '"/discover' '"/$app/discover';
sub_filter '"/requests' '"/$app/requests';
sub_filter '"/issues' '"/$app/issues';
sub_filter '"/site.webmanifest' '"./site.webmanifest';
# Setting settings paths so that they don't match the generic replace
sub_filter 'route:"/settings/main' 'route:"/settings/main';
sub_filter 'regex:/^\/settings\/main' 'regex:/^\/settings\/main';
sub_filter 'route:"/settings/password' 'route:"/settings/password';
sub_filter 'regex:/^\/settings\/password' 'regex:/^\/settings\/password';
sub_filter 'route:"/settings/permissions' 'route:"/settings/permissions';
sub_filter 'regex:/^\/settings\/permissions' 'regex:/^\/settings\/permissions';
sub_filter 'route:"/settings/notifications' 'route:"/settings/notifications';
sub_filter 'regex:/^\/settings\/notifications' 'regex:/^\/settings\/notifications';
# Generic route and regex replace
sub_filter 'route:"/' 'route:"/$app/';
sub_filter 'regex:/^\/' 'regex:/^\/$app_esc\/';
sub_filter 'regex:/\/' 'regex:/\/$app_esc\/';

}

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>

markus-li commented 2 years ago

After a nice chat with @danshilm at Discord I revisited my sub_filter rules to make sure Web Push and PWA was working, it turned out they needed some additional tuning. I don't know if it works on iPhone, but it works in Chrome on my Samsung phone. If Overseerr would run in a subfolder (just about anything so that rewrites can go against the subfolder instead of /) by default this could probably be shortened to a few lines.

Due to the many special corner cases etc this is probably very brittle and could break at next update, but this is what I came up with:

location ^~ /pods/direct/overseerr {
    ## Set environment variables for use with SSO
    set $service_unit "podman-overseerr";
    set $service_name_pretty "Overseerr";

    set $app 'pods/direct/overseerr';
    set $app_esc 'pods\/direct\/overseerr';

    # Remove /pods/direct/overseerr path to pass to the app
    rewrite ^/pods/direct/overseerr/?(.*)$ /$1 break;
    proxy_pass http://127.0.0.1:5055; # NO TRAILING SLASH

    # Redirect location headers
    proxy_redirect ^ /$app;
    proxy_redirect /setup /$app/setup;
    proxy_redirect /login /$app/login;

    # Sub filters to replace hardcoded paths
    proxy_set_header Accept-Encoding "";
    sub_filter_once off;
    sub_filter_types *;

    # HREF
    sub_filter 'href="/"' 'href="/$app/"';
    sub_filter 'href="/login"' 'href="/$app/login"';
    sub_filter 'href:"/"' 'href:"/$app/"'; 

    ## Capture some things which shouldn't change
    sub_filter '.id,"/' '.id,"/';
    sub_filter '"/settings/main' '"/settings/main';
    sub_filter '"/settings/password' '"/settings/password';
    sub_filter '"/settings/permissions' '"/settings/permissions';
    sub_filter '"/settings/notifications/email' '"/$app/settings/notifications/email';
    sub_filter 'webPushEnabled?"/settings/notifications/webpush"' 'webPushEnabled?"/settings/notifications/webpush"';
    sub_filter '"/settings/notifications/webpush' '"/$app/settings/notifications/webpush';
    sub_filter '"/settings/notifications/pushbullet' '"/$app/settings/notifications/pushbullet';
    sub_filter '"/settings/notifications/pushover' '"/$app/settings/notifications/pushover';
    # sub_filter '"/settings/notifications/pushover' '"/settings/notifications/pushover';
    sub_filter '"/settings/notifications' '"/settings/notifications';

    ## Now the remaining settings paths are ok to change
    sub_filter '"/settings' '"/$app/settings';

    ## Default filters:
    sub_filter '\/_next' '\/$app_esc\/_next';
    sub_filter '/_next' '/$app/_next';
    sub_filter '/api/v1' '/$app/api/v1';
    sub_filter '/login/plex/loading' '/$app/login/plex/loading';
    sub_filter '/images/' '/$app/images/';

    ## Route-specific filters:
    sub_filter '"/sw.js"' '"/$app/sw.js"';
    sub_filter '"/offline.html' '"/$app/offline.html';
    sub_filter '"/android-' '"/$app/android-';
    sub_filter '"/apple-' '"/$app/apple-';
    sub_filter '"/favicon' '"/$app/favicon';
    sub_filter '"/logo_' '"/$app/logo_';
    sub_filter '"/profile' '"/$app/profile';
    sub_filter '"/users' '"/$app/users';
    sub_filter '"/movie' '"/$app/movie';
    sub_filter '"/tv' '"/$app/tv';
    ### These are needed for request management
    # It looks like this one rule can be used intead of the below 3
    sub_filter '="/".concat' '="/$app/".concat';
    # sub_filter 't="/".concat(w,"/").concat(y,"?manage=1"' 't="/$app/".concat(w,"/").concat(y,"?manage=1"';
    # sub_filter 's="/".concat(N,"/").concat(y,"?manage=1"' 's="/$app/".concat(N,"/").concat(y,"?manage=1"';
    # sub_filter 't="/".concat(b,"/").concat(y,"?manage=1"' 't="/$app/".concat(b,"/").concat(y,"?manage=1"';
    ###

    # Fix WebPush action URL:
    sub_filter 'actionUrl: payload' 'actionUrl: \'/$app\' + payload';

    sub_filter '"/person' '"/$app/person';
    sub_filter '"/collection' '"/$app/collection';
    sub_filter '"/discover' '"/$app/discover';
    sub_filter '"/requests' '"/$app/requests';
    sub_filter '"/issues' '"/$app/issues';
    sub_filter '"/site.webmanifest' '"/$app/site.webmanifest';
    # Setting settings paths so that they don't match the generic replace

    # For routes in /profile
    sub_filter 'route:"/settings/password' 'route:"/settings/password';
    sub_filter 'regex:/^\/settings\/password' 'regex:/^\/settings\/password';
    sub_filter 'route:"/settings/permissions' 'route:"/settings/permissions';
    sub_filter 'regex:/^\/settings\/permissions' 'regex:/^\/settings\/permissions';
    sub_filter 'route:"/settings/main",regex:/\/settings(\/main)?' 'route:"/settings/main",regex:/\/settings(\/main)?';            
    sub_filter 'route:"/settings/notifications/webpush",regex:/\/settings\/notifications\/webpush/,' 'route:"/settings/notifications/webpush",regex:/\/settings\/notifications\/webpush/,';
    sub_filter 'route:"/settings/notifications/pushbullet",regex:/\/settings\/notifications\/pushbullet/}' 'route:"/settings/notifications/pushbullet",regex:/\/settings\/notifications\/pushbullet/}';
    sub_filter 'route:"/settings/notifications/pushover",regex:/\/settings\/notifications\/pushover/}' 'route:"/settings/notifications/pushover",regex:/\/settings\/notifications\/pushover/}';
    sub_filter 'route:"/settings/notifications' 'route:"/$app/settings/notifications';
    sub_filter 'regex:/^\/settings\/notifications' 'regex:/^\/$app_esc\/settings\/notifications';

    # Generic route and regex replace
    sub_filter 'route:"/' 'route:"/$app/';
    sub_filter 'regex:/^\/' 'regex:/^\/$app_esc\/';
    sub_filter 'regex:/\/' 'regex:/\/$app_esc\/';
}
# code: language=nginx insertSpaces=true tabSize=4
SteffanCline commented 2 years ago

If Overseerr was changed to use relevant paths rather than / wouldn’t that solve the issue too?

css/file.casimages/file.png ……etc Rather than /css/file.cas/images/file.png ……etc

ramkrishna757575 commented 2 years ago

After a nice chat with @danshilm at Discord I revisited my sub_filter rules to make sure Web Push and PWA was working, it turned out they needed some additional tuning. I don't know if it works on iPhone, but it works in Chrome on my Samsung phone. If Overseerr would run in a subfolder (just about anything so that rewrites can go against the subfolder instead of /) by default this could probably be shortened to a few lines.

Due to the many special corner cases etc this is probably very brittle and could break at next update, but this is what I came up with:

location ^~ /pods/direct/overseerr {
    ## Set environment variables for use with SSO
    set $service_unit "podman-overseerr";
    set $service_name_pretty "Overseerr";

    set $app 'pods/direct/overseerr';
    set $app_esc 'pods\/direct\/overseerr';

    # Remove /pods/direct/overseerr path to pass to the app
    rewrite ^/pods/direct/overseerr/?(.*)$ /$1 break;
    proxy_pass http://127.0.0.1:5055; # NO TRAILING SLASH

    # Redirect location headers
    proxy_redirect ^ /$app;
    proxy_redirect /setup /$app/setup;
    proxy_redirect /login /$app/login;

    # Sub filters to replace hardcoded paths
    proxy_set_header Accept-Encoding "";
    sub_filter_once off;
    sub_filter_types *;

    # HREF
    sub_filter 'href="/"' 'href="/$app/"';
    sub_filter 'href="/login"' 'href="/$app/login"';
    sub_filter 'href:"/"' 'href:"/$app/"'; 

    ## Capture some things which shouldn't change
    sub_filter '.id,"/' '.id,"/';
    sub_filter '"/settings/main' '"/settings/main';
    sub_filter '"/settings/password' '"/settings/password';
    sub_filter '"/settings/permissions' '"/settings/permissions';
    sub_filter '"/settings/notifications/email' '"/$app/settings/notifications/email';
    sub_filter 'webPushEnabled?"/settings/notifications/webpush"' 'webPushEnabled?"/settings/notifications/webpush"';
    sub_filter '"/settings/notifications/webpush' '"/$app/settings/notifications/webpush';
    sub_filter '"/settings/notifications/pushbullet' '"/$app/settings/notifications/pushbullet';
    sub_filter '"/settings/notifications/pushover' '"/$app/settings/notifications/pushover';
    # sub_filter '"/settings/notifications/pushover' '"/settings/notifications/pushover';
    sub_filter '"/settings/notifications' '"/settings/notifications';

    ## Now the remaining settings paths are ok to change
    sub_filter '"/settings' '"/$app/settings';

    ## Default filters:
    sub_filter '\/_next' '\/$app_esc\/_next';
    sub_filter '/_next' '/$app/_next';
    sub_filter '/api/v1' '/$app/api/v1';
    sub_filter '/login/plex/loading' '/$app/login/plex/loading';
    sub_filter '/images/' '/$app/images/';

    ## Route-specific filters:
    sub_filter '"/sw.js"' '"/$app/sw.js"';
    sub_filter '"/offline.html' '"/$app/offline.html';
    sub_filter '"/android-' '"/$app/android-';
    sub_filter '"/apple-' '"/$app/apple-';
    sub_filter '"/favicon' '"/$app/favicon';
    sub_filter '"/logo_' '"/$app/logo_';
    sub_filter '"/profile' '"/$app/profile';
    sub_filter '"/users' '"/$app/users';
    sub_filter '"/movie' '"/$app/movie';
    sub_filter '"/tv' '"/$app/tv';
    ### These are needed for request management
    # It looks like this one rule can be used intead of the below 3
    sub_filter '="/".concat' '="/$app/".concat';
    # sub_filter 't="/".concat(w,"/").concat(y,"?manage=1"' 't="/$app/".concat(w,"/").concat(y,"?manage=1"';
    # sub_filter 's="/".concat(N,"/").concat(y,"?manage=1"' 's="/$app/".concat(N,"/").concat(y,"?manage=1"';
    # sub_filter 't="/".concat(b,"/").concat(y,"?manage=1"' 't="/$app/".concat(b,"/").concat(y,"?manage=1"';
    ###

    # Fix WebPush action URL:
    sub_filter 'actionUrl: payload' 'actionUrl: \'/$app\' + payload';

    sub_filter '"/person' '"/$app/person';
    sub_filter '"/collection' '"/$app/collection';
    sub_filter '"/discover' '"/$app/discover';
    sub_filter '"/requests' '"/$app/requests';
    sub_filter '"/issues' '"/$app/issues';
    sub_filter '"/site.webmanifest' '"/$app/site.webmanifest';
    # Setting settings paths so that they don't match the generic replace

    # For routes in /profile
    sub_filter 'route:"/settings/password' 'route:"/settings/password';
    sub_filter 'regex:/^\/settings\/password' 'regex:/^\/settings\/password';
    sub_filter 'route:"/settings/permissions' 'route:"/settings/permissions';
    sub_filter 'regex:/^\/settings\/permissions' 'regex:/^\/settings\/permissions';
    sub_filter 'route:"/settings/main",regex:/\/settings(\/main)?' 'route:"/settings/main",regex:/\/settings(\/main)?';            
    sub_filter 'route:"/settings/notifications/webpush",regex:/\/settings\/notifications\/webpush/,' 'route:"/settings/notifications/webpush",regex:/\/settings\/notifications\/webpush/,';
    sub_filter 'route:"/settings/notifications/pushbullet",regex:/\/settings\/notifications\/pushbullet/}' 'route:"/settings/notifications/pushbullet",regex:/\/settings\/notifications\/pushbullet/}';
    sub_filter 'route:"/settings/notifications/pushover",regex:/\/settings\/notifications\/pushover/}' 'route:"/settings/notifications/pushover",regex:/\/settings\/notifications\/pushover/}';
    sub_filter 'route:"/settings/notifications' 'route:"/$app/settings/notifications';
    sub_filter 'regex:/^\/settings\/notifications' 'regex:/^\/$app_esc\/settings\/notifications';

    # Generic route and regex replace
    sub_filter 'route:"/' 'route:"/$app/';
    sub_filter 'regex:/^\/' 'regex:/^\/$app_esc\/';
    sub_filter 'regex:/\/' 'regex:/\/$app_esc\/';
}
# code: language=nginx insertSpaces=true tabSize=4

This seems to be working. Thanks a lot 😃

BaldissaraMatheus commented 2 years ago

After a nice chat with @danshilm at Discord I revisited my sub_filter rules to make sure Web Push and PWA was working, it turned out they needed some additional tuning. I don't know if it works on iPhone, but it works in Chrome on my Samsung phone. If Overseerr would run in a subfolder (just about anything so that rewrites can go against the subfolder instead of /) by default this could probably be shortened to a few lines.

Due to the many special corner cases etc this is probably very brittle and could break at next update, but this is what I came up with:


location ^~ /pods/direct/overseerr {
    ## Set environment variables for use with SSO
    set $service_unit "podman-overseerr";
    set $service_name_pretty "Overseerr";

    set $app 'pods/direct/overseerr';
    set $app_esc 'pods\/direct\/overseerr';
    ...

This configuration didn't work well for me. When requesting a movie, overseerr seems to be prefixing radarr's root folder with the base path as well, causing the Missing Root Folder error in radarr

Edit: Removing sub_filter '"/movie' '"/$app/movie'; seems to fix the issue

stale[bot] commented 1 year ago

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.

dwk001 commented 1 year ago

I saw this was marked stale, so I am commenting to keep it alive. I don't want this closed until it can somehow be implemented. I would happily pay $50 towards dev work of this feature.

triesmon commented 1 year ago

I'd also like to see this. Would prefer to use a subpath for security reasons and the filter workaround doesn't meet security or ease of maintenance requirements. Changing the subpath should be a fairly easy process with modern programs.

johnistheman commented 1 year ago

I added this line to enable the new image caching feature:

sub_filter '/imageproxy/' '/$app/imageproxy/';

But something isn't working quite right still. Maybe there is something else needed?

On the first page load of a movie detail page, the URI for the image will be for example:

https://domain.com/imageproxy/t/p/w600_and_h900_bestv2/blah.jpg

This doesn't load. I reload the page (doing nothing else) and now the URI for the is: https://domain.com/overseerr/imageproxy/t/p/w600_and_h900_bestv2/blah.jpg

This image does load. Reloading the page the image keeps working. If I go back to Discover, then click in to the movie again, the image isn't loading and reloading the page resolves it again.

zachi40 commented 1 year ago

I added this line to enable the new image caching feature:

sub_filter '/imageproxy/' '/$app/imageproxy/';

But something isn't working quite right still. Maybe there is something else needed?

On the first page load of a movie detail page, the URI for the image will be for example:

https://domain.com/imageproxy/t/p/w600_and_h900_bestv2/blah.jpg

This doesn't load. I reload the page (doing nothing else) and now the URI for the is: https://domain.com/overseerr/imageproxy/t/p/w600_and_h900_bestv2/blah.jpg

This image does load. Reloading the page the image keeps working. If I go back to Discover, then click in to the movie again, the image isn't loading and reloading the page resolves it again.

I added this line to enable the new image caching feature:

sub_filter '/imageproxy/' '/$app/imageproxy/';

But something isn't working quite right still. Maybe there is something else needed?

On the first page load of a movie detail page, the URI for the image will be for example:

https://domain.com/imageproxy/t/p/w600_and_h900_bestv2/blah.jpg

This doesn't load. I reload the page (doing nothing else) and now the URI for the is: https://domain.com/overseerr/imageproxy/t/p/w600_and_h900_bestv2/blah.jpg

This image does load. Reloading the page the image keeps working. If I go back to Discover, then click in to the movie again, the image isn't loading and reloading the page resolves it again.

You can try it like this sub_filter '/imageproxy' '/$app/imageproxy'; it works for me