skip to Main Content

I want run one node-red instance (inside docker) and expose http endpoints on two ports, for example :1880 and :1881. How to configure node-red to listen on two ports?

2

Answers


  1. I’m a bit curious as to why you want to do this. But there are definitely ways to do it. Here’s an example using docker-compose and nginx. Nginx will listen on ports 1880 and 1881 and pass any requests on to the node-red container.

    Create an Nginx config file called nginx.conf with this content

    server {
        listen 1880;
    
        location / {
            proxy_pass http://nodered:1880/;
        }
    }
    
    server {
        listen 1881;
    
        location / {
            proxy_pass http://nodered:1880/;
        }
    }
    

    and a docker-compose.yml file with this

    version: '3'
    
    services:
      nodered:
        image: nodered/node-red
      proxy:
        image: nginx:alpine
        volumes:
          - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
        ports:
          - 1880:1880
          - 1881:1881
    

    Spin up the containers using docker compose up -d and you should be able to reach node-red on both http://localhost:1880/ and on http://localhost:1881/.

    Login or Signup to reply.
  2. The correct solution here is NOT 2 http ports.

    You should move the editor off the root path and move the dashboard to the root. The editor root is controlled by httpAdminRoot option in the settings.js and the dashboard root is ui.path option. See the docs here:
    https://nodered.org/docs/user-guide/runtime/configuration

    You should then ensure that the adminAuth is enabled to ensure that only you can log into the editor.

    How to secure the editor is documented here:

    https://nodered.org/docs/user-guide/runtime/securing-node-red

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search