-
Notifications
You must be signed in to change notification settings - Fork 0
/
proxy
34 lines (27 loc) · 970 Bytes
/
proxy
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
const fs = require('fs');
const https = require('https');
const httpProxy = require('http-proxy');
// Load your HTTPS certificates
const privateKey = fs.readFileSync('key.pem', 'utf8');
const certificate = fs.readFileSync('cert.pem', 'utf8');
const credentials = { key: privateKey, cert: certificate };
const targetIp = 'https://your.target.ip.address:5011'; // Replace with your target IP and port
const proxy = httpProxy.createProxyServer({
target: targetIp,
secure: false // Setting this to false will ignore self-signed certificates on the target server
});
const server = https.createServer(credentials, (req, res) => {
proxy.web(req, res);
});
server.on('error', (err) => {
console.error(`Server error: ${err}`);
});
proxy.on('error', (err, req, res) => {
res.writeHead(500, {
'Content-Type': 'text/plain'
});
res.end(`Proxy error: ${err}`);
});
server.listen(5011, () => {
console.log('HTTPS Proxy server running on port 5011');
});