You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2017/04/10 17:12:04 UTC
[2/4] incubator-trafficcontrol git commit: moves server.js to root of
project
moves server.js to root of project
Project: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/commit/c2d55c79
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/tree/c2d55c79
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/diff/c2d55c79
Branch: refs/heads/master
Commit: c2d55c79bca9dcda439dceec59c79375269c075d
Parents: f6e6afe
Author: Jeremy Mitchell <mi...@gmail.com>
Authored: Mon Apr 10 10:54:36 2017 -0600
Committer: Dewayne Richardson <de...@apache.org>
Committed: Mon Apr 10 11:11:57 2017 -0600
----------------------------------------------------------------------
traffic_ops/experimental/ui/grunt/express.js | 2 +-
traffic_ops/experimental/ui/server.js | 98 +++++++++++++++++++++++
traffic_ops/experimental/ui/server/server.js | 98 -----------------------
3 files changed, 99 insertions(+), 99 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c2d55c79/traffic_ops/experimental/ui/grunt/express.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/grunt/express.js b/traffic_ops/experimental/ui/grunt/express.js
index b6be794..97c3bda 100644
--- a/traffic_ops/experimental/ui/grunt/express.js
+++ b/traffic_ops/experimental/ui/grunt/express.js
@@ -20,7 +20,7 @@
module.exports = {
dev: {
options: {
- script: './server/server.js',
+ script: './server.js',
node_env: 'dev'
}
}
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c2d55c79/traffic_ops/experimental/ui/server.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/server.js b/traffic_ops/experimental/ui/server.js
new file mode 100644
index 0000000..002ab61
--- /dev/null
+++ b/traffic_ops/experimental/ui/server.js
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+var constants = require('constants'),
+ express = require('express'),
+ http = require('http'),
+ https = require('https'),
+ path = require('path'),
+ fs = require('fs'),
+ morgan = require('morgan'),
+ errorhandler = require('errorhandler'),
+ timeout = require('connect-timeout');
+
+var config = require('./conf/config'),
+ logStream = fs.createWriteStream(config.log.stream, { flags: 'a' }),
+ useSSL = config.useSSL;
+
+// Disable for self-signed certs in dev/test
+process.env.NODE_TLS_REJECT_UNAUTHORIZED = config.reject_unauthorized;
+
+var app = express();
+// Add a handler to inspect the req.secure flag (see
+// http://expressjs.com/api#req.secure). This allows us
+// to know whether the request was via http or https.
+app.all ("/*", function (req, res, next) {
+ if (useSSL && !req.secure) {
+ var headersHost = req.headers.host.split(':');
+ var httpsUrl = 'https://' + headersHost[0] + ':' + config.sslPort + req.url;
+ // request was via http, so redirect to https
+ res.redirect(httpsUrl);
+ } else {
+ next();
+ }
+});
+
+app.use(express.static(config.files.static));
+app.use(morgan('combined', {
+ stream: logStream,
+ skip: function (req, res) { return res.statusCode < 400 }
+}));
+app.use(errorhandler());
+app.use(timeout(config.timeout));
+
+app.use(require('connect-livereload')({
+ port: 35728,
+ excludeList: ['.woff', '.flv']
+}));
+
+// Enable reverse proxy support in Express. This causes the
+// the "X-Forwarded-Proto" header field to be trusted so its
+// value can be used to determine the protocol. See
+// http://expressjs.com/api#app-settings for more details.
+app.enable('trust proxy');
+
+// Startup HTTP Server
+var httpServer = http.createServer(app);
+httpServer.listen(config.port);
+
+if (useSSL) {
+ //
+ // Supply `SSL_OP_NO_SSLv3` constant as secureOption to disable SSLv3
+ // from the list of supported protocols that SSLv23_method supports.
+ //
+ var sslOptions = {};
+ sslOptions['secureOptions'] = constants.SSL_OP_NO_SSLv3;
+
+ sslOptions['key'] = fs.readFileSync(config.ssl.key);
+ sslOptions['cert'] = fs.readFileSync(config.ssl.cert);
+ sslOptions['ca'] = config.ssl.ca.map(function(cert){
+ return fs.readFileSync(cert);
+ });
+
+ // Startup HTTPS Server
+ var httpsServer = https.createServer(sslOptions, app);
+ httpsServer.listen(config.sslPort);
+
+ sslOptions.agent = new https.Agent(sslOptions);
+}
+
+console.log("Traffic Ops UI Port : %s", config.port);
+console.log("Traffic Ops UI Proxy Port : %s", config.proxyPort);
+console.log("Traffic Ops UI SSL Port : %s", config.sslPort);
http://git-wip-us.apache.org/repos/asf/incubator-trafficcontrol/blob/c2d55c79/traffic_ops/experimental/ui/server/server.js
----------------------------------------------------------------------
diff --git a/traffic_ops/experimental/ui/server/server.js b/traffic_ops/experimental/ui/server/server.js
deleted file mode 100644
index a6037eb..0000000
--- a/traffic_ops/experimental/ui/server/server.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-var constants = require('constants'),
- express = require('express'),
- http = require('http'),
- https = require('https'),
- path = require('path'),
- fs = require('fs'),
- morgan = require('morgan'),
- errorhandler = require('errorhandler'),
- timeout = require('connect-timeout');
-
-var config = require('../conf/config'),
- logStream = fs.createWriteStream(config.log.stream, { flags: 'a' }),
- useSSL = config.useSSL;
-
-// Disable for self-signed certs in dev/test
-process.env.NODE_TLS_REJECT_UNAUTHORIZED = config.reject_unauthorized;
-
-var app = express();
-// Add a handler to inspect the req.secure flag (see
-// http://expressjs.com/api#req.secure). This allows us
-// to know whether the request was via http or https.
-app.all ("/*", function (req, res, next) {
- if (useSSL && !req.secure) {
- var headersHost = req.headers.host.split(':');
- var httpsUrl = 'https://' + headersHost[0] + ':' + config.sslPort + req.url;
- // request was via http, so redirect to https
- res.redirect(httpsUrl);
- } else {
- next();
- }
-});
-
-app.use(express.static(config.files.static));
-app.use(morgan('combined', {
- stream: logStream,
- skip: function (req, res) { return res.statusCode < 400 }
-}));
-app.use(errorhandler());
-app.use(timeout(config.timeout));
-
-app.use(require('connect-livereload')({
- port: 35728,
- excludeList: ['.woff', '.flv']
-}));
-
-// Enable reverse proxy support in Express. This causes the
-// the "X-Forwarded-Proto" header field to be trusted so its
-// value can be used to determine the protocol. See
-// http://expressjs.com/api#app-settings for more details.
-app.enable('trust proxy');
-
-// Startup HTTP Server
-var httpServer = http.createServer(app);
-httpServer.listen(config.port);
-
-if (useSSL) {
- //
- // Supply `SSL_OP_NO_SSLv3` constant as secureOption to disable SSLv3
- // from the list of supported protocols that SSLv23_method supports.
- //
- var sslOptions = {};
- sslOptions['secureOptions'] = constants.SSL_OP_NO_SSLv3;
-
- sslOptions['key'] = fs.readFileSync(config.ssl.key);
- sslOptions['cert'] = fs.readFileSync(config.ssl.cert);
- sslOptions['ca'] = config.ssl.ca.map(function(cert){
- return fs.readFileSync(cert);
- });
-
- // Startup HTTPS Server
- var httpsServer = https.createServer(sslOptions, app);
- httpsServer.listen(config.sslPort);
-
- sslOptions.agent = new https.Agent(sslOptions);
-}
-
-console.log("Traffic Ops UI Port : %s", config.port);
-console.log("Traffic Ops UI Proxy Port : %s", config.proxyPort);
-console.log("Traffic Ops UI SSL Port : %s", config.sslPort);