[HTTPS] on nodejs and Centos using openssl
1. First of all, you have to create private & public key - Install the system-specific openssl from this link . - Create openssl.cfg http://www.flatmtn.com/article/setting-openssl-create-certificates.html - Set the following variable : set OPENSSL_CONF=LOCATION_OF_SSL_INSTALL\bin\openssl.cfg Update the path : set Path=...Other Values here...;LOCATION_OF_SSL_INSTALL\bin - Run > openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 - Double click at localhost.crt 2. Create "server.js" const { createServer } = require('https'); const { parse } = require('url'); const next = require('next'); const fs = require('fs'); const dev = process.env.NODE_ENV !== 'production'; const app = next({ dev }); const handle = app.getRequestHandler(); const httpsOptions = { key: fs.readFileSync('./certificates/localhost.key'), cert: fs.readFileSync('./certif...



Comments
Post a Comment