# Setting HTTPS in Docker Compose

**URL:** <https://discourse.nodered.org/t/setting-https-in-docker-compose/77933>\
**Category:** General\
**Tags:** docker\
**Created:** [25 April 2023 21:30 UTC](https://discourse.nodered.org/t/setting-https-in-docker-compose/77933 "2023-04-25T21:30:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![oliver.es](https://avatars.discourse-cdn.com/v4/letter/o/dc4da7/32.png) [@oliver.es](https://discourse.nodered.org/u/oliver.es)\
**Post date:** [25 April 2023 21:30 UTC](https://discourse.nodered.org/t/setting-https-in-docker-compose/77933/1 "2023-04-25T21:30:07Z")

</div>

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.

```auto
 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

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [25 April 2023 23:54 UTC](https://discourse.nodered.org/t/setting-https-in-docker-compose/77933/2 "2023-04-25T23:54:40Z")

</div>

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

```auto
volumes:
      - ./node-red-data:/data

```

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

```auto
/** 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`

---

<div class="post-metadata">

**Author:** ![oliver.es](https://avatars.discourse-cdn.com/v4/letter/o/dc4da7/32.png) [@oliver.es](https://discourse.nodered.org/u/oliver.es)\
**Post date:** [26 April 2023 07:20 UTC](https://discourse.nodered.org/t/setting-https-in-docker-compose/77933/3 "2023-04-26T07:20:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 April 2023 11:47 UTC](https://discourse.nodered.org/t/setting-https-in-docker-compose/77933/4 "2023-04-26T11:47:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 June 2023 11:47 UTC](https://discourse.nodered.org/t/setting-https-in-docker-compose/77933/5 "2023-06-25T11:47:47Z")

</div>

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