diff --git a/configs/standalone.js b/configs/standalone.js index df9358f1..fd27207f 100644 --- a/configs/standalone.js +++ b/configs/standalone.js @@ -41,7 +41,9 @@ module.exports = function(config, optimist) { .boolean("inProcessLocalFs") .describe("inProcessLocalFs", "Whether to run localfs in same process for debugging.") .default("inProcessLocalFs", config.inProcessLocalFs) - .boolean("useBrowserCache"); + .boolean("useBrowserCache") + .describe("useBrowserCache", "Use window.caches api if available for faster loading, requires https://") + .describe("secure", "path to file containing ssl certificate (can be generated using scripts/create-cert.sh)"); } var argv = optimist.argv; @@ -112,7 +114,7 @@ module.exports = function(config, optimist) { if (argv.secure) { var certPath = path.isAbsolute(argv.secure) ? argv.secure : path.join(__dirname, "..", argv.secure); - var key = require("fs").readFileSync(certPath , "utf8"); + var key = require("fs").readFileSync(certPath, "utf8"); config.secure = { key: key.match(/^(-+BEGIN RSA PRIVATE KEY[\s\S]*END RSA PRIVATE KEY-+)/m)[0], cert: key.match(/^(-+BEGIN CERTIFICATE[\s\S]*END CERTIFICATE-+)/m)[0], @@ -198,7 +200,10 @@ module.exports = function(config, optimist) { }, "./c9.vfs.server/vfs.server", "./c9.error/logger.raygun_noop", - "./c9.preview/preview.handler", + { + packagePath: "./c9.preview/preview.handler", + selfSignedSSL: config.secure + }, "./c9.vfs.server/cache", "./c9.vfs.server/download", "./c9.vfs.server/filelist", diff --git a/plugins/c9.preview/preview.handler.js b/plugins/c9.preview/preview.handler.js index d2e9839e..a5288db7 100644 --- a/plugins/c9.preview/preview.handler.js +++ b/plugins/c9.preview/preview.handler.js @@ -165,7 +165,8 @@ define(function(require, exports, module) { path: parsedUrl.path, hostname: parsedUrl.hostname, port: parsedUrl.port, - headers: req.headers + headers: req.headers, + rejectUnauthorized: !options.selfSignedSSL }, function(request) { if (request.statusCode >= 400 || request.headers["content-type"] == "text/x-error") handleError(request); diff --git a/plugins/c9.vfs.standalone/standalone.js b/plugins/c9.vfs.standalone/standalone.js index 48955e9e..a1b64eca 100644 --- a/plugins/c9.vfs.standalone/standalone.js +++ b/plugins/c9.vfs.standalone/standalone.js @@ -141,8 +141,11 @@ function plugin(options, imports, register) { api.authenticate()(req, res, next); }, previewHandler.getProxyUrl(function() { + var serverOptions = options.options; + var host = serverOptions.host; + if (host == "0.0.0.0") host = "localhost"; return { - url: "http://localhost:" + options.options.port + "/vfs" + url: (serverOptions.secure ? "https://" : "http://") + host + ":" + serverOptions.port + "/vfs" }; }), previewHandler.proxyCall()