# Enable End-to-End TLS (HTTPS to Container) in Temporal Web

**URL:** <https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817>\
**Category:** Community Support\
**Tags:** web-ui, tls\
**Created:** [August 27, 2021, 7:46pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817 "2021-08-27T19:46:37Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnesenfamily](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arnesenfamily](https://community.temporal.io/u/arnesenfamily)\
**Post date:** [August 27, 2021, 7:46pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/1 "2021-08-27T19:46:37Z")

</div>

I’ll preface my comment with, I’ve read [this post](https://community.temporal.io/t/how-to-enable-ssl-in-temporal-web/1794/5) which includes my exact error. However, I suspect that my error is that I am misunderstanding the purpose of these ENV vars:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/e/eeff43a35d3a824f9b654d8d0784494b423b5338.png)

My initial thought was that these env vars are what the nodejs web app would use to support HTTPS usage in the browser. However, after some investigation, it appears that these env vars are for mutual authentication to the frontend services (i.e. client certs for access to the frontend service). The certificates I’m providing in these env vars are not being added to the frontend services as valid client certs as they are used to enable HTTPS for the temporal web ingress. I think this is the reason for the ssl errors I’m seeing the temporal web app logs.

I have a requirement to support end-to-end TLS encryption for EKS-based applications (SSL to the container) but after looking at the temporal web source, I’m wondering if it’s even possible. It looks like the temporal web is based on [Koa](https://koajs.com/) and based on the [koa docs regarding enabling HTTPS](https://koajs.com/#app-listen-), I’m thinking that the current temporal web code does not currently support running the koa app as an https server, and thus does not support end-to-end encryption.

Can someone confirm my finding?

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [August 27, 2021, 8:30pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/2 "2021-08-27T20:30:12Z")

</div>

Yes, you are correct in your understanding

Th current web doesn’t support out of the box HTTPS. The TLS certs are used to establish connection to a secured Temporal service

As an option you can use nginx or envoy etc to enable HTTPS

In the next generation of UI we will be adding HTTPS out of the box. Repos:

> **[GitHub - temporalio/ui-server: Web UI backed by Golang server](https://github.com/temporalio/ui-server)**
>
> Web UI backed by Golang server. Contribute to temporalio/ui-server development by creating an account on GitHub.

> **[GitHub - temporalio/ui: The next-generation UI for Temporal.](https://github.com/temporalio/ui)**
>
> The next-generation UI for Temporal. Contribute to temporalio/ui development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![arnesenfamily](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arnesenfamily](https://community.temporal.io/u/arnesenfamily)\
**Post date:** [August 27, 2021, 8:48pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/3 "2021-08-27T20:48:36Z")

</div>

I like that the new UI is go-based. Any idea when it’ll be officially released?

Using the Koa docs, I was able to get HTTPS working locally using a slightly customized version of [server.js](https://github.com/temporalio/web/blob/master/server.js).

```auto
const app = require('./server/index'),
  port = Number(process.env.TEMPORAL_WEB_PORT) || 8088,
  production = process.env.NODE_ENV === 'production',
  sslEnabled = process.env.TEMPORAL_WEB_USE_HTTPS || false;

if (sslEnabled) {
  const https = require('https');
  const fs = require('fs');
  const options = {
    key: fs.readFileSync(process.env.TEMPORAL_WEB_TLS_KEY_PATH),
    cert: fs.readFileSync(process.env.TEMPORAL_WEB_TLS_CERT_PATH),
  };

  https.createServer(options, app.init().callback()).listen(port);
} else {
  app.init().listen(port);
}

console.log('temporal-web up and listening on port ' + port);

if (!production) {
  console.log('webpack is compiling...');
}

```

I added 3 new ENV vars to control SSL for temporal web’s UI.

- TEMPORAL\_WEB\_USE\_HTTPS - boolean flag to control whether https is enabled or not
- TEMPORAL\_WEB\_TLS\_KEY\_PATH - path to temporal web’s cert private key
- TEMPORAL\_WEB\_TLS\_CERT\_PATH - path to temporal web’s cert

Now if I could only get the docker build working so I can publish this version of temporal web to my container registry.

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [August 27, 2021, 9:51pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/4 "2021-08-27T21:51:57Z")

</div>

if you are having issues with building docker lmk happy to help

---

<div class="post-metadata">

**Author:** ![arnesenfamily](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arnesenfamily](https://community.temporal.io/u/arnesenfamily)\
**Post date:** [August 30, 2021, 2:34pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/5 "2021-08-30T14:34:19Z")

</div>

@Ruslan, I was able to get the docker build working. I am behind a corporate proxy which causes issues when I tried to run the make command, so I manually downloaded the proto files, which seemed to work. Then I had issues running the npm install and run commands inside a docker container, again due to the proxy. Outside the docker container, I was able to run the commands just fine as I’ve already accounted for the proxy in my local npm cli. So I ran these commands locally from the root of the repo

```auto
npm install --production
npm run build-production

```

Then I deleted the grpc module as it had a platform-specific binary. Then to get the node\_modules copied into the docker image, I first had to comment out the node\_modules line in the .dockerignore file.

```auto
#node_modules
npm-debug.log

```

Then add a few lines to the dockerFile to make sure the cache was clean and then to copy the node\_modules directory into the image before running any npm commands.

```auto
# Install app dependencies
COPY package*.json ./
RUN npm cache clean --force
COPY ./node_modules ./node_modules
RUN npm install --production

```

I was able to build and run the docker image locally after these changes. I am pushing it to ECR now and will test it.

---

<div class="post-metadata">

**Author:** ![arnesenfamily](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arnesenfamily](https://community.temporal.io/u/arnesenfamily)\
**Post date:** [August 30, 2021, 4:17pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/6 "2021-08-30T16:17:58Z")

</div>

So, slight modification to the server.js file was required after some testing.

```auto
const app = require('./server/index'),
  port = Number(process.env.TEMPORAL_WEB_PORT) || 8088,
  production = process.env.NODE_ENV === 'production',
  sslEnabled = process.env.TEMPORAL_WEB_USE_HTTPS || false;

if (sslEnabled === "true") {
  const https = require('https');
  const fs = require('fs');

  console.log('temporal-web ssl enabled');
  https
    .createServer(
      {
        key: fs.readFileSync(process.env.TEMPORAL_WEB_TLS_KEY_PATH, 'utf-8'),
        cert: fs.readFileSync(process.env.TEMPORAL_WEB_TLS_CERT_PATH, 'utf-8'),
      },
      app.init().callback()
    )
    .listen(port);
} else {
  console.log('temporal-web ssl not enabled');
  app.init().listen(port);
}

console.log('temporal-web up and listening on port ' + port);

if (!production) {
  console.log('webpack is compiling...');
}

```

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [August 30, 2021, 5:30pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/7 "2021-08-30T17:30:57Z")

</div>

> [@arnesenfamily](#):
>
> I like that the new UI is go-based. Any idea when it’ll be officially released?

no promises for the release timeline. Can say the new UI is one of the top priorities

---

<div class="post-metadata">

**Author:** ![arnesenfamily](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arnesenfamily](https://community.temporal.io/u/arnesenfamily)\
**Post date:** [August 30, 2021, 5:37pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/8 "2021-08-30T17:37:45Z")

</div>

Would it be possible to incorporate my changes into the current node-based web code in the short term?

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [August 30, 2021, 5:40pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/9 "2021-08-30T17:40:57Z")

</div>

yes the changes look good, feel free to send a PR

---

<div class="post-metadata">

**Author:** ![arnesenfamily](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arnesenfamily](https://community.temporal.io/u/arnesenfamily)\
**Post date:** [August 30, 2021, 6:36pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/10 "2021-08-30T18:36:11Z")

</div>

Do I need to open an issue for this PR?

 ![image](https://us1.discourse-cdn.com/flex016/uploads/temporal/original/2X/d/df1a6e0032761d6b740a2675a8413a8395ff1cc8.png)

---

<div class="post-metadata">

**Author:** ![Ruslan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/ruslan/32/66_2.png) [@Ruslan](https://community.temporal.io/u/Ruslan)\
**Post date:** [August 30, 2021, 6:37pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/11 "2021-08-30T18:37:32Z")

</div>

> [@arnesenfamily](#):
>
> Do I need to open an issue for this PR?

It’s good without opening

---

<div class="post-metadata">

**Author:** ![arnesenfamily](https://avatars.discourse-cdn.com/v4/letter/a/87869e/32.png) [@arnesenfamily](https://community.temporal.io/u/arnesenfamily)\
**Post date:** [August 30, 2021, 7:13pm UTC](https://community.temporal.io/t/enable-end-to-end-tls-https-to-container-in-temporal-web/2817/12 "2021-08-30T19:13:29Z")

</div>

[PR](https://github.com/temporalio/web/pull/379) Submitted
