I build my project in expressjs and I want to deploy it on a specific port. I deployed it and its working fine over my AWS EC2 instance (Ubuntu) but the issue is that it runs on HTTP, not HTTPS. So I research how we can run expressjs on HTTPS and the only way I found is given below:
var fs = require("fs"),
http = require("https");
var privateKey = fs.readFileSync('sslcert/server.key').toString();
var certificate = fs.readFileSync('sslcert/server.crt').toString();
var credentials = {key: privateKey, cert: certificate};
var server = http.createServer(credentials,function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello World
');
});
server.listen(8000);
But the issue with this method is that it requiring cert and key files to enable HTTPS. I am using public ACM and AWS doesn't provide files for that. I tried another method using the library https://www.npmjs.com/package/express-sslify. It redirects my expressjs to HTTPS but it gives SSL error. SSL is already deployed on my website using AWS ACM public certificate and it's working fine.
Kindly guide what steps I will be required to make my expressjs project compatible with AWS ACM.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…