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?
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
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
and a docker-compose.yml file with this
Spin up the containers using
docker compose up -d
and you should be able to reach node-red on bothhttp://localhost:1880/
and onhttp://localhost:1881/
.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 thesettings.js
and the dashboard root isui.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