What is the good practice for locally testing a website that has both an http and https frontend?
Here is my server code:
const app = require('../app'),
http = require('http'),
https = require('https'),
fs = require('fs');
var httpServer = http.createServer(app);
httpServer.listen(8000, () => {
console.debug('HTTP Server running');
});
const httpsServer = https.createServer({
key: fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem'),
cert: fs.readFileSync('/etc/letsencrypt/live/example.com/cert.pem'),
ca: fs.readFileSync('/etc/letsencrypt/live/example.com/chain.pem'),
}, app);
httpsServer.listen(8001, () => {
console.error('HTTPS Server running');
});
Only the remote server has the certificates, so when tested with http://localhost:8000 the local server obviously complains about the certificates missing ; I tried to create dummy placeholder files, but that didn't fool it:
library: 'PEM routines',
error message= function: 'get_name',
error message= reason: 'no start line',
error message= code: 'ERR_OSSL_PEM_NO_START_LINE'
Do I have to retrieve the cert files and install them on every dev machine? Can't I conditionnaly (conditionnal to the protocol / port number) declare my httpsServer and its options?