-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (30 loc) · 988 Bytes
/
app.js
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
var http = require('http');
httpProxy = require('http-proxy'),
config = require('./config.json');
var proxy = httpProxy.createProxyServer({});
http.createServer(function(req, res) {
proxy.on("error", function(e){console.log(e);});
if(req.headers['user-agent.match'] !== 'ELB-HealthChecker\/1.0')
{
if(req.headers['x-forwarded-proto']=== 'http'){
res.writeHead(301,{
'Location': 'https://www.verpix.me'+req.url
});
res.end();
}
else
{
if(req.url.match(/\/api\/(.*)/g))
{
proxy.web(req, res,
{ target: config.apiProxy },
function(e){console.log(e)});
}
else
{
proxy.web(req, res, { target: config.viewerProxy},
function(e){console.log(e)});
}
}
}
}).listen(config.port);