-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
29 lines (24 loc) · 734 Bytes
/
app.js
File metadata and controls
29 lines (24 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
const http = require('http')
const https = require('https')
const fs = require('fs')
const hostname = '0.0.0.0';
const port = 80;
const server = http.createServer((req, res) => {
res.writeHead(301, { Location: `https://${req.headers.host}${req.url}` });
res.end();
});
const options = {
key: fs.readFileSync('key.pem'),
cert: fs.readFileSync('cert.pem')
}
const sserver = https.createServer({}, (req, res) => {
res.writeHead(200);
res.setHeader('Content-Type', 'text/plain');
res.end('Hello Security');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
sserver.listen(443, hostname, () => {
console.log(`SServer running at http://${hostname}:443/`);
});