Not quite understanding how httpAdminRoot works

Hi folks,

I need to do a lot of catching up from other discussions, but first I need to finish an issue with my overal Node-RED setup...

I need to setup a (Tailscale) reverse proxy that exposes Node-RED at some path "my_root". So when I navigate to http(s)://my_host_name/my_root, the Node-RED flow editor should be displayed.

Since I am by far a specialist about this kind of thing, I would really appreciate if somebody could enlighten me!

First attempt - without httpAdminRoot

So the flow editor runned originally at the base path. Which means I configured my reverse proxy like this:

http://my_host_name/my_root --> http://localhost:1880

When I navigate to http://my_host_name/my_root the Node-RED html page is being fetched from the base path (http://localhost:1880) without problems:
image

However none of the other files can be found, because those requests go to the base path of my proxy (http://my_host_name/red/...), while my proxy is listening only to requests to my_root (http://my_host_name/my_root/red/...):

So the proxy has no idea what to do with those requests.

Second attempt - with httpAdminRoot

Since Node-RED should get all these files from my_root to solve this, I thought I should adjust the httpAdminRoot in my settings.js file:
image

When I navigate now to http://my_host_name/my_root the Node-RED html page cannot be fetched anymore, since that is now being served at my_root:
image

So I thought that I could solve this by changing my reverse proxy, so that I get redirected to my_root (where the html is being served):

http://my_host_name/my_root --> http://localhost:1880/my_root

And then indeed I can fetch the Node-RED html page from my_root, but the other files still cannot be fetched:

For some reason those files are NOT being fetched from http://my_host_name/my_root/red/... but from the base path ( http://my_host_name/red/...). I thought that all files would be served under httpAdminRoot?

Thanks for reading!!
Bart

Not familiar with Tailscale, can only really comment on NGINX.

I always move the editor to /red.

I proxy the / path to https://localhost:1880/ simply because I don't need to run any other none node-red endpoints on this server and then have a sub-location of /red/ (note the trailing slashes, they tend to be important for proxying) which is where I proxy websockets as well.

A separate /red/ui sub-location (https://my.public.domain/red/ui/) is proxied to http://localhost:1880/ui/ for dashboard. I can do the same for any UIBUILDER endpoints as well of course.

I should say that I don't actually need to proxy anything on my home server since anything externally accessible actually goes through Cloudflare Zero Trust but it is useful to have some kind of working config for questions like this.

Hey Julian,

Really appreciate your input! It gives my brain some food to think about...

During my lunch break, I had a quick discussion with chatgpt about this. Summarized:

  1. I set my httpAdminRoot:

    image

  2. So now my initial html file is available at http://localhost:1880/my_root

  3. When I now navigate to https://my_tailscale_hostname/my_root I can fetch my Node-RED file which contains a bunch of relative file paths (i.e. they don't start with '/'):

  4. However these file paths can still not be accessed (http status 404). That is because the file paths are relative to the url. Which means the browser appends the relative URL to your current url. But the browser appends the relative url to the last directory in your url, and omits filenames at the end. So if you are for example navigating to http://some_directory/some_file_name then it will become http://some_directory/some_relative_path which means some_file_name is obviously ignored.

  5. So I simply had to add a / at the end of my url, which means I now navigate to http://localhost:1880/my_root/. Now the relative paths will be appended to it like http://localhost:1880/my_root/red/red.min.js. And that works because thanks to the httpAdminRoot my file is located at that location.

I did not test yet if everything works fine, but this is quite promising...

Bart

2 Likes

Phew, I thought you were going to make me think through all that proxy path stuff again - bad enough last night!! :grinning:

Yes, those pesky trailing slashes are a nightmare. So very easy to get wrong.

Glad you can move forwards.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.