HTTPS/TLS Basics for Backend Devs
On this page
HTTPS and TLS
The https module wraps HTTP with TLS encryption. In production, TLS may be terminated at a load balancer or directly inside Node.
import https from 'https';
import fs from 'fs';
const options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
};
https.createServer(options, (req, res) => {
res.end('secure');
}).listen(443);
Architectural Decision
Terminating TLS at a reverse proxy improves scalability. Direct TLS in Node is common for smaller deployments or internal services.