HTTPS和多个服务器

HTTPS

为了创建使用HTTPS协议的应用程序,我们必须传递一个options对象:

const httpsOptions = { key: fs.readFileSync('./secrets/private-key.pem'), cert: fs.readFileSync('./secrets/public-certificate.pem') }; const app = await NestFactory.create(ApplicationModule, { httpsOptions, } await app.listen(3000

多个同时服务器

express实例的完全控制提供了一种简单的方法来创建多个同时在不同端口上侦听的服务器。

const httpsOptions = { key: fs.readFileSync('./secrets/private-key.pem'), cert: fs.readFileSync('./secrets/public-certificate.pem') }; const server = express( const app = await NestFactory.create(ApplicationModule, server await app.init( http.createServer(server).listen(3000 https.createServer(httpsOptions, server).listen(443