Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs https server

var https = require('https');
var fs = require('fs');
var options = {
     key: fs.readFileSync('/path/to/privkey.pem'),
     cert: fs.readFileSync('/path/to/fullchain.pem'),
     ca: fs.readFileSync('/path/to/chain.pem')
}
var server = https.createServer(options, handlerFunction);
server.listen(8080, '127.0.0.1');
Comment

node https server setup

var fs = require('fs');
var http = require('http');
var https = require('https');
var privateKey  = fs.readFileSync('certificates/key.pem', 'utf8');
var certificate = fs.readFileSync('certificates/cert.pem', 'utf8');

var credentials = {key: privateKey, cert: certificate};
var express = require('express');
var app = express();

// your express configuration here

var httpServer = http.createServer(app);
var httpsServer = https.createServer(credentials, app);

// For http
httpServer.listen(8080);
// For https
httpsServer.listen(8443);

app.get('/', function (req, res) {
    res.header('Content-type', 'text/html');
    return res.end('<h1>Hello, Secure World!</h1>');
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: find one with specofoc id mongoose 
Javascript :: outer width jquery 
Javascript :: Javascript Regex for non-negative numbers 
Javascript :: prevent paste in input 
Javascript :: get data from url in angular 
Javascript :: tsconfig.json not generated 
Javascript :: math.factorial 
Javascript :: javascript format float 
Javascript :: addclass javascript 
Javascript :: example of pre increment in js 
Javascript :: change file name in node.js 
Javascript :: javascript math.random 
Javascript :: How to get input file using js 
Javascript :: js draw circle 
Javascript :: api testing 
Javascript :: iframe reload parent page 
Javascript :: get parameters from url 
Javascript :: check if the document is ready js 
Javascript :: vue js copy text to clipboard 
Javascript :: convert date to readable format javascript 
Javascript :: javascript WeakSet Methods 
Javascript :: axios try catch 
Javascript :: render react in blaze 
Javascript :: react scrollTop smooth 
Javascript :: javascript for of 
Javascript :: js random string from array 
Javascript :: convert string number with commas decimal to number javascript 
Javascript :: how to draw ellipse in javascript canvas 
Javascript :: js select by data attribute 
Javascript :: ERESOLVE unable to resolve dependency tree 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =