2020年2月11日 星期二
NodeJS Express with HTTPS on Windows 10
https://timonweb.com/posts/running-expressjs-server-over-https/
1. Install
Install Win64OpenSSL_Light-1_1_1d.exe with all default values
http://slproweb.com/products/Win32OpenSSL.html
Win64 OpenSSL v1.1.1d Light (EXE) 3MB
http://slproweb.com/download/Win64OpenSSL_Light-1_1_1d.exe
2. Create
Go to a new folder, run
"C:\Program Files\OpenSSL-Win64\bin\openssl.exe" req -nodes -new -x509 -keyout server.key -out server.cert
This gives
server.cert
server.key
3. main.js code
var opn = require('opn');
opn('https://127.0.0.1:8081/');
var fs = require('fs');
var https = require('https');
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World');
});
var server = https.createServer({
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.cert')
}, app).listen(8081, function () {
var host = server.address().address;
var port = server.address().port;
console.log("Example app listening at http://%s:%s", host, port);
});
End
訂閱:
張貼留言 (Atom)
2023 Promox on Morefine N6000 16GB 512GB
2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...
-
On CentOS 7, using yum install gives you cmake version 2.8.11 [root@thrift1 ~]# cat /etc/*release CentOS Linux release 7.2.1511 (Core) ...
-
Synology DSM 5.2 on Virtual Box Files On my Google Drive "2016DSM5.2" or download link below (3 files total: pat, iso, exe) ...
-
Static ZeroMQ (difficult setup) cd /d C:\ mkdir Repos cd /d C:\Repos\ git clone https://github.com/Microsoft/vcpkg cd /d C:\Repos\v...
沒有留言:
張貼留言