-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (33 loc) · 932 Bytes
/
index.js
File metadata and controls
38 lines (33 loc) · 932 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
30
31
32
33
34
35
36
37
38
#!/usr/bin/env node
const argv = require('yargs').argv
const httpProxy = require('http-proxy');
const fs = require('fs');
const path = require('path');
let listenPort = argv.port || 80
var proxy = httpProxy.createServer({
target: {
host: 'localhost',
port: listenPort,
},
ssl: {
cert: fs.readFileSync(path.resolve(__dirname, './test.crt'), 'utf8'),
key: fs.readFileSync(path.resolve(__dirname, './test.key'), 'utf8')
},
ws: true,
secure: true
}).listen(443, ()=>{
console.log("Proxy https in 443 ,listen "+listenPort)
});
// const tls = require("tls"),
// net = require("net"),
// fs = require("fs");
// let server = tls.createServer({
// key: fs.readFileSync("test.key"),
// cert: fs.readFileSync("test.cert"),
// }, (s1) => {
// let s2 = net.createConnection(7678, "127.0.0.1", () => {
// s1.pipe(s2);
// s2.pipe(s1);
// });
// });
// server.listen(443);