'use strict';
const express = require('express')
const http = require('http')
const https = require('https')
const fs = require('fs')
const path = require('path')
const domain = 'xxxx.com'
const app = express()
app.get('*',function(req, res){
res.redirect('https://' + domain + req.path);
});
app.use(express.static(path.join(__dirname,'public')))
http.createServer(app).listen(80, function(){
console.log('HTTP listening on port 80 33');
});
const appSecure = express();
appSecure.use(express.static(path.join(__dirname,'public')))
var options = {
key: fs.readFileSync('/mydata/key/1.key'),
cert: fs.readFileSync('/mydata/key/1.crt'),
};
https.createServer(options, appSecure).listen(443, function(){
console.log('HTTPS listening on port 443');
});
服务器正常运行的,脱敏后的代码