Setting HTTPS in Docker Compose

Hello,

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.

 node-red:
    image: nodered/node-red:latest
    container_name: node-red
    ports:
      - '1880:1880'
    environment:
      - NODE_RED_TLS_CERT=/etc/node-red/certs/server.crt
      - NODE_RED_TLS_KEY=/etc/node-red/certs/server.key
    volumes:
      - '/etc/letsencrypt/live/mydomain.com/fullchain.pem:/etc/node-red/certs/server.crt:ro'
      - '/etc/letsencrypt/live/mydomain.com/privkey.pem:/etc/node-red/certs/server.key:ro'
    networks:
      - 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)

Thx

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

volumes:
      - ./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.