Setting HTTPS in Docker Compose


trying to run Node RED in Docker via Docker Compose yaml file. I need to load with HTTPS enabled and path to certificate files.

This is example of Docker Compose file.

    image: nodered/node-red:latest
    container_name: node-red
      - '1880:1880'
      - NODE_RED_TLS_CERT=/etc/node-red/certs/server.crt
      - NODE_RED_TLS_KEY=/etc/node-red/certs/server.key
      - '/etc/letsencrypt/live/'
      - '/etc/letsencrypt/live/'
      - internal-network

But it does not work.

Does Node RED support evirnoment variables to set up HTTPS? Or do you know any other method without copying settings file outside container? (maybee problems with Node RED updates with static settings file)


i read the documentation for Node-red Docker and didnt see any enviroment variables for certs
like you tried to do in your Docker compose file.

After testing this what worked for me is to create a folder where your yaml file is node-red-data
and map it to the container to /data which is the internal folder the NR container uses for the flows, settings.js file etc

      - ./node-red-data:/data

In node-red-data copy your cert files and then edit your settings.js section to enable https

/** Option 1: static object */
   https: {
     key: require("fs").readFileSync('/data/cert-key.pem'),
     cert: require("fs").readFileSync('/data/cert.pem')

spin up your docker-compose and visit https://<node-red-ip>:1880

Docker version of the Node-RED copying the settings.js file to persistent storage out of the container. If I will make some changes and in the future, there will be a new version of Node-RED with new functions which require new sections in the settings.js file, there will be a problem I guess because after pulling the new version of the Node-RED, settings.js file will not be overwritten. This is the reason why I want to set up HTTPS via ENV or add the HTTPS configuration to the end of the configuration file whenever the container starts.

That should not be the case. Even a standard Node-RED install initialises a default settings.js if one does not exist but it will not overwrite one that does. Which is why you should review changes to the settings file when you update Node-RED.

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