Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
363 views
in Technique[技术] by (71.8m points)

node.js - Using Let's Encrypt certificates on DigitalOcean App Platform for a HTTPS node app

I'm used to deploying HTTPS Node apps on DigitalOcean servers using Docker, the Express framework and the https package like this:

const https = require('https');

const app = express();

// ...

const ssl = {
  key: fs.readFileSync(process.env.PRIVATE_KEY),
  cert: fs.readFileSync(process.env.CERT),
  ca: fs.readFileSync(process.env.CHAIN),
};

const server = https.createServer(ssl, app);
server.listen({ port }, () => {
  // ...
});

My app is inside a Docker container, but I expose the certicates that are on the droplet with the "v" option when I do docker run, like this:

-v /etc/letsencrypt/:/etc/letsencrypt

Finally, my Docker container is passed environment variables so that my Node app can know the paths to the various certificates files. For example,

CHAIN=/etc/letsencrypt/live/mydomain.com/chain.pem

And now, my Node app can read the certificates and create an HTTPS server with them.

I don't know if this setup is ideal, but it works well.


Now, I'm wondering how to do the same using the DigitalOcean App Platform.
So far, what I've done is this:

But I can't get it to work with the certificates and therefore, have my HTTPS app work.
Does anyone here have an idea?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.6k users

...