uWebSockets.js/examples/ServerName.js
2020-08-17 03:59:39 +02:00

27 lines
717 B
JavaScript
Vendored

/* Minimal SSL example using ServerNameIndication */
const uWS = require('../dist/uws.js');
const port = 9001;
const app = uWS.SSLApp({
key_file_name: 'misc/key.pem',
cert_file_name: 'misc/cert.pem',
passphrase: '1234'
}).addServerName("localhost", {
key_file_name: 'misc/key.pem',
cert_file_name: 'misc/cert.pem',
passphrase: '1234'
}).removeServerName("localhost").addServerName("localhost", {
key_file_name: 'misc/key.pem',
cert_file_name: 'misc/cert.pem',
passphrase: '1234'
}).get('/*', (res, req) => {
res.end('Hello World!');
}).listen(port, (token) => {
if (token) {
console.log('Listening to port ' + port);
} else {
console.log('Failed to listen to port ' + port);
}
});