Tdarr icon indicating copy to clipboard operation
Tdarr copied to clipboard

Unable to use Nginx with Tdarr V2 on Windows

Open Flippage opened this issue 4 years ago • 16 comments

Describe the bug With V2, when you set a base URL (e.g. "/base") in the web-ui, it does not change the ROOT_URL, nor does it update API calls. When running NGINX, this means that instead of API calls in TDARR pointing to http://localhost/tdarr/api/v2, it instead points to http://localhost/api/v2 Because I'm also using Organizr, this API point is already in use by the Organizr V2 api (plus, Tdarr api folder isn't in that directory)

In addition, the landing page appears when you go to http://localhost:8265, but that should not work as only the base URL should work, in this case http://localhost:8265/base.

Also, applying suggested environment variables in CMD does not work: image

To Reproduce Run Tdarr_Server, Tdarr_Node, and Tdarr_Webui and attempt to get it working behind Nginx proxy. Worked fine on the old TDARR, as I was able to include BASE and ROOT_URL variables when launching it from CMD.

Expected behavior Setting the Base URL in the web-ui, should fully set the URL base, including API calls and the landing page. I would also expect the settings to save to the config file, making them more accessible for editing.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version: V2 preview

Flippage avatar Jan 28 '21 00:01 Flippage

I'm flat out unable to set the baseURL in the Options tab. When I change it (there's no apply button, so I think it saves..?) nginx can't connect, and the parameter is cleared after I reboot the container which makes me think it's not actually setting (or clearing on reboot). I'm using unRAID's docker setup with Beta 1.3003 tdarr_aio

joshbgosh10592 avatar Jan 30 '21 10:01 joshbgosh10592

I have the same issue as @Flippage, but my tdarr is running in docker and my nginx is running on ubuntu.

@joshbgosh10592 you seem to have a different issue, as this is about tdarr v2

theg00s3 avatar Jan 31 '21 17:01 theg00s3

I have not really used nginx so will need to see if I can get it running on Windows this week.

HaveAGitGat avatar Feb 01 '21 17:02 HaveAGitGat

+1 Same issue both on Docker and running without Docker.

cxtal avatar Feb 02 '21 01:02 cxtal

Can confirm on a linux system. I don't think it has anything to do with the operating system. Setting the following environment variables for the docker container does not seem to change the base path:

ROOT_URL: "http://localhost/tdarr"
BASE: "/tdarr"

Madic- avatar Feb 03 '21 09:02 Madic-

I think you’re right. If I set the base path to say /tdarr and visit localhost:8265/tdarr/tdarr I get an error and if i just go to /tdarr it just doesn't load properly, but then i can navigate to /tdarr/tdarr fine from there. it's really weird

theg00s3 avatar Feb 03 '21 10:02 theg00s3

This issue continues to exist in 2.00.09. Setting the baseurl only appears to impact loading specific pages, but does not update the landing page and, more importantly, does not update the API path, breaking the ability to reverse proxy effectively.

regoras avatar May 18 '21 23:05 regoras

My "solution" (which isn't really a solution) was to put tdarr on its own subdomain (so now it's tdarr.example.com instead of example.com/tdarr

theg00s3 avatar May 19 '21 05:05 theg00s3

Any updates on this one? Still present in 2.00.10

cvele avatar Sep 27 '21 15:09 cvele

Hi all, sorry for the delay. I believe this is now fixed in the acceptance 2.00.12 containers so if one of you can quickly run one of the following commands and verify it's working as you'd expect. All you need to do now is set the basePath env/config variable on the server, you'll then see in the log on startup the webui address:

Tdarr_WebUI running at http://localhost:8265/examplePath/test

Windows CMD:

docker run -ti ^
             -e "serverIP=0.0.0.0" ^
             -e "webUIPort=8265" ^
             -e "serverPort=8266" ^
             -e "basePath=/examplePath/test" ^
             --network="bridge" ^
             -p 8265:8265 ^
             -p 8266:8266 ^
             -e PUID=1000 ^
             -e PGID=1000 ^
             --log-opt max-size=10m ^
             --log-opt max-file=5 ^
             haveagitgat/tdarr_acc

Windows Powershell

docker run -ti `
             -e "serverIP=0.0.0.0" `
             -e "webUIPort=8265" `
             -e "serverPort=8266" `
             -e "basePath=/examplePath/test" `
             --network="bridge" `
             -p 8265:8265 `
             -p 8266:8266 `
             -e PUID=1000 `
             -e PGID=1000 `
             --log-opt max-size=10m `
             --log-opt max-file=5 `
             haveagitgat/tdarr_acc

Posix:

docker run -ti \
             -e "serverIP=0.0.0.0" \
             -e "webUIPort=8265" \
             -e "serverPort=8266" \
             -e "basePath=/examplePath/test" \
             --network="bridge" \
             -p 8265:8265 \
             -p 8266:8266 \
             -e PUID=1000 \
             -e PGID=1000 \
             --log-opt max-size=10m \
             --log-opt max-file=5 \
             haveagitgat/tdarr_acc

I've noticed that if you run it from a git bash terminal on Windows, it for some reason appends C:/Program Files/Git to the basePath but that's to do with Git bash variables that start with a '/', not Tdarr.

The basePath will show up on the options tab as a non-configurable value: image

https://tdarr.io/docs/pre-releases

Thanks

HaveAGitGat avatar Dec 03 '21 06:12 HaveAGitGat

@HaveAGitGat Thanks for all your work on this great software.

This still doesn't seem to be working correctly in 2.00.12.

image

image

image

image

I have set the basePath to /tdarr but api and socket requests are not honoring that setting.

danomoseley avatar Dec 10 '21 16:12 danomoseley

I get the same result that @danomoseley is getting

au5ton avatar Dec 23 '21 09:12 au5ton

@HaveAGitGat same results as @au5ton and @danomoseley on my side - this bug remains unfixed.

rix1337 avatar Feb 06 '22 13:02 rix1337

I'll take another look at this.

HaveAGitGat avatar Feb 10 '22 08:02 HaveAGitGat

The broken path prefix applies not only to windows btw.

rix1337 avatar Mar 17 '22 09:03 rix1337

I'm close to get it partially working by using this Nginx configuration.

location ^~ /tdarr {
set $app 'tdarr';

# Remove /tdarr path to pass to the app
rewrite ^/tdarr/?(.*)$ /$1 break;
proxy_pass http://ADDRESS:8265/;

# Redirect location headers
proxy_redirect ^ /$app;

# Sub filters to replace hardcoded paths
proxy_set_header Accept-Encoding "";
sub_filter_once off;
sub_filter_types *;
sub_filter 'href="/"' 'href="/$app"';
sub_filter 'href:"/"' 'href:"/$app"';
sub_filter '/api/' '/$app/api/';
sub_filter '/images/' '/$app/images/';

sub_filter '/socket.io' '/$app/socket.io';
}

The following endpoints are failing to load properly (due to the filters - I'm not sure how to fix this).

https://tdarr.io/api/v2/versions (Due to /api/ rewrite.)

https://tdarrs.s3.us-west-000.backblazeb2.com/data/images/splash_bg.jpg (Due to / rewrite/)

/socket.io (Web Socket connection endpoint.)

If anyone has any suggestions, that would be great!

Emalton avatar Apr 18 '22 22:04 Emalton

Is there any news on this? Just about to try and put this behind Organizr.

Swiftnesses avatar Mar 11 '23 18:03 Swiftnesses

I've given up and use FileFlows instead.

Emalton avatar Mar 11 '23 18:03 Emalton

Yeah sorry didn't get round to fixing this (had a go but ran into some issues as not too familiar with nginx). Yeah think John/Revens over on FileFlows handles it (would ping him but think he's at work now) and there's also Unmanic which I think might do it.

Will have another crack at it later this week or next.

HaveAGitGat avatar Mar 13 '23 20:03 HaveAGitGat

Spoke to Reven as he says FileFlows doesn't officially support this and we were a bit unsure of the use case (instead of e.g. using subdomain or something like that).

Eitherway the issue with Tdarr is a bit of a chicken and egg problem in that the web UI needs to know the baseURL before contacting the server to get the baseURL.

To get around this I've made it so if you end the url in tdarr then the UI will autodetect you're using a custom url and correct the api and socket.io requests. No variable needs to be set for Tdarr_Server as we'll do it all using nginx.

So, for example, you'd set your nginx config as

       location ^~ /home/tdarr {
            # remove /home/tdarr from the request
            rewrite ^/home/tdarr(/.*)$ $1 break;

            proxy_pass http://127.0.0.1:8265/;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }    

So you can sue urls such as:

/hometdarr
/home/tdarr
/tdarr
/test/abc/tdarr

Make sure to add a trailing slash e.g. http://localhost/home/tdarr/ as without it the screen in just blank (not 100% sure why atm)

Can try it using:

https://tdarrs.s3.us-west-000.backblazeb2.com/dev/versions/2.00.20/linux_x64/Tdarr_Server_2023_03_24T19_05_39z.zip
docker pull haveagitgat/tdarr_acc:dev_2.00.20_2023_03_24T19_05_39z

Hope that helps.

HaveAGitGat avatar Mar 24 '23 18:03 HaveAGitGat

I've improved the nginx config so no trailing slash needed (as I previously mentioned), added to the docs here:

https://docs.tdarr.io/docs/installation/extra#using-a-base-path-with-tdarr-webui

So should be able to close this now. Ty.

HaveAGitGat avatar Mar 27 '23 18:03 HaveAGitGat

2.00.20 released

HaveAGitGat avatar Apr 03 '23 18:04 HaveAGitGat

This seems to work for me. Thank you!

danomoseley avatar Apr 04 '23 00:04 danomoseley

Great :)

HaveAGitGat avatar Apr 04 '23 17:04 HaveAGitGat