Accessing node-red on port 1880 through public url with nginx or caddy

Hello, I’m trying to use the public device url to access other services on my device using caddy, but it just won’t load the /nodered page and there are no errors. If anyone could give any suggestions that would be great…

my files:

part of my docker-compose:

node-red:
    build: ./node-red
    ports:
      - '1880:1880'
    devices:
      - '/dev/mem:/dev/mem'
      - '/dev/gpiomem:/dev/gpiomem'
      - '/dev/i2c-1:/dev/i2c-1'
    restart: always
    volumes:
      - 'ftpdata:/data'
    privileged: true
    network_mode: host
    labels:
      io.balena.features.supervisor-api: '1'

 
   caddy:
    build: ./caddy
    restart: unless-stopped
    network_mode: host
    privileged: true
    ports:
      - '80:80'
      - '443:443'
    volumes:
      - caddy_data:/data
      - caddy_config:/config
  

dockerfile:

  FROM caddy:2.6.4

# Copy Caddyfile to /etc/caddy/Caddyfile
COPY Caddyfile /etc/caddy/Caddyfile

# Format the Caddyfile
RUN caddy fmt --overwrite /etc/caddy/Caddyfile


Caddyfile:

:80 {
    redir https://{host}{uri}
}

:443 {
    tls internal
    reverse_proxy /nodered/* http://localhost:1880
}

1 Like

Hello @cheezymcsquibble

What error do you get here? Could you please share more?

I’m happy to try to reproduce tomorrow!

the page doesn’t load, only a ‘too many redirects’ is shown. Interesting detail: if I let the port 80 forward directly to localhost:1880, WITHOUT using the /nodered/* path, then it will load node-red successfully. But this isn’t what I’m looking for, because I have multiple services that I need to access. Could it be that the balena public url doesn’t allow path handling somehow?

@mpous did you manage to reproduce it?

No i couldn’t @cheezymcsquibble

do you have a dummy repo that i can test?

Thanks!

I managed to do it using this post: Add nginx reverse proxy - #3 by ajlennon

The trick is to make sure every service’s base url has to be changed to accept the subfolder, so for node-red the settings.js had to be changed to include:

httpAdminRoot: '/node-red',

Also the Traefik solution is more practical because I only need to change the docker compose file for each change. With caddy I need to purge my data each time and upload a new caddy file.

1 Like