Access service by IP-address and prefix

Hi,

I am trying to access a service on the local network (Node-RED, but it can be any other service) using the IP address of the host machine and a URL prefix (e.g., http://192.168.56.189/mynodered). This access is managed via a reverse proxy. The service must be protected by basic authentication, which is functioning correctly. Additionally, other services should be accessible using different prefixes. It is important that domain names are not used in this setup.

Docker compose file:

version: '3.8'

services:
  traefik:
    image: traefik:v3.0
    command:
      - "--api.insecure=true"
      - "--providers.docker=true"
      - "--entrypoints.web.address=:80"
    ports:
      - "80:80"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    networks:
      - proxy-net

  nodered:
    image: nodered/node-red:latest
    container_name: nodered
    networks:
      - proxy-net
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.nodered.rule=PathPrefix(`/mynodered`)"
      - "traefik.http.middlewares.nodered-stripprefix.stripprefix.prefixes=/mynodered"
      - "traefik.http.routers.nodered.middlewares=nodered-stripprefix,nodered-auth"
      - "traefik.http.services.nodered.loadbalancer.server.port=1880"
      - "traefik.http.middlewares.nodered-auth.basicauth.users=test:$$2a$12$$ZWVe/KRVHDgwiI3zjtKkrOp8YrhiyEVec7OCgjTRjn6icsamY384O"  # username: test password: test

networks:
  proxy-net:
    name: proxy-net
    external: true

When I enter the address http://192.168.56.189/mynodered, I am prompted for authentication, which I can successfully pass with the correct credentials. However, after logging in, I am presented with an empty page.

Browser console outputs:

The resource from “http://192.168.56.189/vendor/jquery/css/base/jquery-ui.min.css?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
The resource from “http://192.168.56.189/vendor/font-awesome/css/font-awesome.min.css?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
The resource from “http://192.168.56.189/red/style.min.css?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
The resource from “http://192.168.56.189/vendor/monaco/style.css?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
The resource from “http://192.168.56.189/vendor/vendor.js?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
Loading failed for the <script> with source “http://192.168.56.189/vendor/vendor.js?v=341f7f7ac7d1”. mynodered:34:47
The resource from “http://192.168.56.189/vendor/monaco/monaco-bootstrap.js?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
The resource from “http://192.168.56.189/red/red.min.js?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
The resource from “http://192.168.56.189/red/main.min.js?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
The resource from “http://192.168.56.189/vendor/monaco/monaco-bootstrap.js?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
Loading failed for the <script> with source “http://192.168.56.189/vendor/monaco/monaco-bootstrap.js?v=341f7f7ac7d1”. mynodered:35:64
The resource from “http://192.168.56.189/red/red.min.js?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
Loading failed for the <script> with source “http://192.168.56.189/red/red.min.js?v=341f7f7ac7d1”. mynodered:36:45
The resource from “http://192.168.56.189/red/main.min.js?v=341f7f7ac7d1” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff). mynodered
Loading failed for the <script> with source “http://192.168.56.189/red/main.min.js?v=341f7f7ac7d1”. mynodered:37:46

Traefik logs:

2024-06-19T14:04:51Z ERR error="accept tcp [::]:80: use of closed network connection" entryPointName=web
2024-06-19T14:04:51Z ERR error="close tcp [::]:80: use of closed network connection" entryPointName=web
2024-06-19T14:04:51Z ERR error="accept tcp [::]:8080: use of closed network connection" entryPointName=traefik
2024-06-19T14:04:51Z ERR error="close tcp [::]:8080: use of closed network connection" entryPointName=traefik

Am I doing something wrong? Thank you for helping.

The usual:

You can’t simply place a GUI web app under a path, even when you remove the prefix.

The initial page will load, it will require additional resources (like /static/script.js), which will not work with your path.

This only works when your app supports setting some kind of "base path".

That’s why the use of sub-domains is usually best practice.

1 Like

Thank you for your response.
So, what you're saying is that there's no way for me to avoid using domain names?

Some apps work, Traefik Dashboard for example does not.

You need to check the docs of your target app if it supports some kind of "base path" or "root path" in the config.