This repository has been archived by the owner on Jul 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
server.js
57 lines (50 loc) · 1.5 KB
/
server.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict';
var app = require('./app.js');
var fs = require('fs');
var express = require('express');
var https = require('https');
var httpProxy = require('http-proxy');
var pem = require('pem');
// Deployment tracking
console.log("PROCESS ENV")
console.log(process.env)
var port = process.env.VCAP_APP_PORT || 8080;
app.set('port', (process.env.PORT || port));
var key = fs.readFileSync('public/ca.key').toString();
var cert = fs.readFileSync('public/ca.crt').toString();
var options = { key: key, cert: cert};
// http
app.listen(port);
console.log('listening at:', port);
// https
// https.createServer(options, app).listen(port, function(){
// console.log("Node app is running at: " + app.get('port'));
// });
// pem.createCertificate({ days: 1, selfSigned: true }, function (err, keys) {
// var httpsOptions = {
// key: keys.serviceKey,
// cert: keys.certificate
// };
//
// var proxy = httpProxy.createProxyServer({
// target: "169.45.79.70",
// port: 8000,
// ws: true,
// secure: false,
// changeOrigin: true
// });
//
// var proxyWebsocket = function (req, socket, head) {
// // replace the target with your signaling server ws url
// proxy.ws(req, socket, head, {
// target: '169.45.79.70',
// port: 8000
// });
// };
//
// var app = express();
// var server = https.createServer(httpsOptions, app);
// server.on('upgrade', proxyWebsocket);
//
// server.listen(8000);
// });