29 lines
678 B
JavaScript
29 lines
678 B
JavaScript
import https from 'https';
|
|
import http from 'http';
|
|
import fs from 'fs';
|
|
|
|
const options = {
|
|
key: fs.readFileSync('./localhost+2-key.pem'),
|
|
cert: fs.readFileSync('./localhost+2.pem')
|
|
};
|
|
|
|
const server = https.createServer(options, (req, res) => {
|
|
// Simple proxy to localhost:3000
|
|
const proxyReq = http.request({
|
|
hostname: 'localhost',
|
|
port: 3000,
|
|
path: req.url,
|
|
method: req.method,
|
|
headers: req.headers
|
|
}, (proxyRes) => {
|
|
res.writeHead(proxyRes.statusCode, proxyRes.headers);
|
|
proxyRes.pipe(res);
|
|
});
|
|
|
|
req.pipe(proxyReq);
|
|
});
|
|
|
|
server.listen(3443, '0.0.0.0', () => {
|
|
console.log('HTTPS Proxy running on https://159.195.9.107:3443');
|
|
});
|