I have the following extremely basic Node.js server:
"use strict";
const http = require("http");
const https = require("https");
const fs = require("fs");
http.createServer((req, res) => {
console.log("regular works");
res.end("Regular response");
}).listen(3000);
https.createServer({
key: fs.readFileSync("/etc/letsencrypt/live/domain.com/privkey.pem"),
cert: fs.readFileSync("/etc/letsencrypt/live/domain.com/cert.pem")
}, (req, res) => {
console.log("secure works");
res.end("Secure response");
}).listen(3001);
I run this as sudo node filename.js
, only because files in /etc/letsencrypt/live
are root-only. I will do this properly later, this is only for testing.
When run, I can hit port 3000 just fine. The server console prints regular works
, and the browser displays Regular response
. However, port 3001 returns an empty response, and no message is printed to the server.
The LetsEncrypt files were generated with ./letsencrypt-auto certonly --standalone -d domain.com --email email@gmail.com --agree-tos
and appear valid.
What am I missing to have the expected result?