/
index.js
63 lines (49 loc) · 2.24 KB
/
index.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
58
59
60
61
62
//redirect http to https
// http://heyrod.com/snippets/redirect-http-to-https-in-expressjs.html
var http = require('http');
var express = require('express');
const { constants } = require('crypto');
var HTTP_PORT = 80;
var HTTPS_PORT = 443;
var http_app = express();
http_app.set('port', HTTP_PORT);
http_app.all('/*', function(req, res, next) {
if (/^http$/.test(req.protocol)) {
var host = req.headers.host.replace(/:[0-9]+$/g, ""); // strip the port # if any
if ((HTTPS_PORT != null) && HTTPS_PORT !== 443) {
return res.redirect("https://" + host + ":" + HTTPS_PORT + req.url, 301);
} else {
return res.redirect("https://" + host + req.url, 301);
}
} else {
return next();
}
});
http.createServer(http_app).listen(HTTP_PORT).on('listening', function() {
return console.log("HTTP to HTTPS redirect app launched.");
});
// Redbird
// WILL NEED TO CHANGE IF NOT USING STATE SSL
var sslobj={
port: 443,
key: 'ssl/docker/privkey28.pem',
cert: 'ssl/docker/fullchain28.pem',
ca: 'ssl/docker/chain28.pem',
secureOptions: constants.SSL_OP_NO_TLSv1 | constants.SSL_OP_NO_TLSv1_1
};
var redbird = require('redbird')({
port: 443,
xfwd: false,
ssl: sslobj});
redbird.register('gis.dola.colorado.gov/apps', 'http://shiny-server:3838', {ssl: true});
redbird.register('gis.dola.colorado.gov/lookups', 'http://demoglookup:4001', {ssl: true});
redbird.register('gis.dola.colorado.gov/capi', 'http://censusapi:4002', {ssl: true});
redbird.register('gis.dola.colorado.gov/cmap', 'http://censusmap:4003', {ssl: true});
redbird.register('gis.dola.colorado.gov/grants', 'http://cogrants:4004', {ssl: true});
redbird.register('gis.dola.colorado.gov/pt2pl', 'http://pt2pl:4005', {ssl: true});
redbird.register('gis.dola.colorado.gov/sd', 'http://sdapi:4006', {ssl: true});
redbird.register('gis.dola.colorado.gov/phantom', 'http://phantom:4007', {ssl: true});
redbird.register('gis.dola.colorado.gov/usda_webmap', 'http://usda_webmap:4009', {ssl: true});
redbird.register('gis.dola.colorado.gov/munis', 'http://muniapi:4010', {ssl: true});
redbird.register('gis.dola.colorado.gov/profiles', 'http://profiles:4012', {ssl: true});
redbird.register('gis.dola.colorado.gov', 'http://website2:4021', {ssl: true});