How to use the createServer function from https
Find comprehensive JavaScript https.createServer code examples handpicked from public code repositorys.
https.createServer creates a HTTPS server instance in Node.js.
GitHub: rlawndks4/mas_back
53 54 55 56 57 58 59 60 61 62
const options = { // letsencrypt로 받은 인증서 경로를 입력해 줍니다. ca: fs.readFileSync("/etc/letsencrypt/live/massage11gu.com/fullchain.pem"), key: fs.readFileSync("/etc/letsencrypt/live/massage11gu.com/privkey.pem"), cert: fs.readFileSync("/etc/letsencrypt/live/massage11gu.com/cert.pem") }; https.createServer(options, app).listen(HTTPS_PORT, '0.0.0.0', function () { console.log("Server on " + HTTPS_PORT); }); }
GitHub: Siwakornzz/CorsFix
572 573 574 575 576 577 578 579 580 581
after(function(done) { stopServer(done); }); before(function() { bad_https_server = https.createServer({ // rejectUnauthorized: false, key: fs.readFileSync(path.join(__dirname, 'key.pem')), cert: fs.readFileSync(path.join(__dirname, 'cert.pem')), }, function(req, res) {
+ 2 other calls in file
How does https.createServer work?
https.createServer
is a method that creates a new HTTPS server instance and takes a configuration object as its argument, which can be used to specify the server's behavior and settings. It listens for incoming requests over the secure HTTPS protocol, using an SSL/TLS certificate to encrypt and authenticate the connection. The server instance can then be used to handle incoming requests and send responses, much like an HTTP server.
24 25 26 27 28 29 30 31 32 33 34 35
const options = { key: fs.readFileSync('certs/key.pem'), cert: fs.readFileSync('certs/cert.pem'), }; var server = https.createServer(options,app).listen(PORT, function(){ console.log("MVSION Installer Status [OK]\nOpen a browser to https://localhost:" + PORT+"/login"); }); // var server = http.createServer(app).listen(PORT, function(){
GitHub: kishank11/formnexuses
32 33 34 35 36 37 38 39 40 41 42
key: fs.readFileSync('./ssl/omniforms_online.key'), cert: fs.readFileSync('./ssl/omniforms_online.crt'), ca: fs.readFileSync('./ssl/omniforms_online.ca-bundle') }; var httpsport = 1337; var server = https.createServer(options, app).listen(httpsport, function () { console.log("Express server listening on port " + httpsport); }); const form = "encbb"
+ 2 other calls in file
Ai Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
const https = require("https"); const fs = require("fs"); const options = { key: fs.readFileSync("private-key.pem"), cert: fs.readFileSync("public-cert.pem"), }; const server = https.createServer(options, (req, res) => { res.writeHead(200); res.end("Hello, World!"); }); server.listen(443, () => { console.log("Server listening on port 443"); });
This code creates an HTTPS server that listens on port 443 and responds to requests with a "Hello, World!" message. The options object contains the private key and public certificate used to authenticate the server, and the https.createServer() method is passed the options object and a callback function that handles incoming requests.
55 56 57 58 59 60 61
https.createServer(options, app).listen(443); } else { options['key'] = fs.readFileSync('privkey.pem'); options['cert'] = fs.readFileSync('cert.pem'); app.listen(PORT); https.createServer(options, app).listen(process.env.PORT + 1 || 443); }
+ 3 other calls in file
5 6 7 8 9 10 11 12 13 14 15 16
const assert = require('assert'); const https = require('https'); const fixtures = require('../common/fixtures'); const server = https.createServer({ key: fixtures.readKey('agent2-key.pem'), cert: fixtures.readKey('agent2-cert.pem'), // Amount of keylog events depends on negotiated protocol // version, so force a specific one:
34 35 36 37 38 39 40 41 42 43 44
cert: fixtures.readKey('agent1-cert.pem') }; for (const { mod, createServer } of [ { mod: http, createServer: http.createServer }, { mod: https, createServer: https.createServer.bind(null, options) }, ]) { const server = createServer(common.mustCall((req, res) => { assert.strictEqual(req.headers.host, hostExpect); assert.strictEqual(req.headers['x-port'], `${server.address().port}`);
https.request is the most popular function in https (32 examples)