diff --git a/packages/ctl/ctl.js b/packages/ctl/ctl.js index 4dff4d587f6..bd4dc84422c 100644 --- a/packages/ctl/ctl.js +++ b/packages/ctl/ctl.js @@ -54,7 +54,8 @@ Ctl.Commands.push({ Ctl.prettyCall(Ctl.findGalaxy(), 'run', [Ctl.myAppName(), 'server', { exitPolicy: 'restart', env: { - METEOR_DEPLOY_CONFIG: JSON.stringify(deployConfig) + METEOR_DEPLOY_CONFIG: JSON.stringify(deployConfig), + ROOT_URL: appConfig.sitename }, ports: { "main": { diff --git a/packages/livedata/stream_client_common.js b/packages/livedata/stream_client_common.js index 7cdf37f9516..1eee855a34b 100644 --- a/packages/livedata/stream_client_common.js +++ b/packages/livedata/stream_client_common.js @@ -52,6 +52,9 @@ var translateUrl = function(url, newSchemeBase, subPath) { url = newSchemeBase + "://" + url; } + if (__meteor_runtime_config__.ABSOLUTE_URL && startsWith(url, "/")) + url = Meteor.absoluteUrl() + url; + if (endsWith(url, "/")) return url + subPath; else diff --git a/packages/meteor/url_server.js b/packages/meteor/url_server.js index ed9b5bb421a..30c9a194326 100644 --- a/packages/meteor/url_server.js +++ b/packages/meteor/url_server.js @@ -1,3 +1,6 @@ if (process.env.ROOT_URL && typeof __meteor_runtime_config__ === "object") __meteor_runtime_config__.ROOT_URL = process.env.ROOT_URL; +if (process.env.ABSOLUTE_URL && + typeof __meteor_runtime_config__ === "object") + __meteor_runtime_config__.ABSOLUTE_URL = true; diff --git a/packages/webapp/webapp_server.js b/packages/webapp/webapp_server.js index a2fc24e29c0..ac9e49d6714 100644 --- a/packages/webapp/webapp_server.js +++ b/packages/webapp/webapp_server.js @@ -239,6 +239,14 @@ var runWebAppServer = function () { "// ##RUNTIME_CONFIG##", "__meteor_runtime_config__ = " + JSON.stringify(__meteor_runtime_config__) + ";"); + var rootUrl = ""; + if (process.env.ABSOLUTE_URL) { + rootUrl = __meteor_runtime_config__.ROOT_URL || process.env.ROOT_URL; + } + boilerplateHtml = boilerplateHtml.replace( + /##ROOT_URL##/g, + rootUrl + ); app.use(function (req, res, next) { if (! appUrl(req.url)) @@ -283,7 +291,11 @@ var runWebAppServer = function () { }; }; -var bindToProxy = function (proxyConfig) { +var bindToProxy = Meteor._bindToProxy = function (proxyConfig) { + + var securePort = proxyConfig.securePort || (proxyConfig.unprivilegedPorts ? 4433 : 443); + var insecurePort = proxyConfig.insecurePort || (proxyConfig.unprivilegedPorts ? 8080 : 80); + var bindPathPrefix = proxyConfig.bindPathPrefix || ""; // XXX also support galaxy-based lookup if (!proxyConfig.proxyEndpoint) throw new Error("missing proxyEndpoint"); @@ -306,10 +318,10 @@ var bindToProxy = function (proxyConfig) { var myHost = os.hostname(); var ddpBindTo = proxyConfig.unprivilegedPorts ? { - ddpUrl: 'ddp://' + proxyConfig.bindHost + ':4433/', - insecurePort: 8080 + ddpUrl: 'ddp://' + proxyConfig.bindHost + ':' + securePort + bindPathPrefix + '/', + insecurePort: insecurePort } : { - ddpUrl: 'ddp://' + proxyConfig.bindHost + '/' + ddpUrl: 'ddp://' + proxyConfig.bindHost + bindPathPrefix + '/' }; // This is run after packages are loaded (in main) so we can use @@ -331,25 +343,29 @@ var bindToProxy = function (proxyConfig) { pid: pid, bindTo: { host: proxyConfig.bindHost, - port: proxyConfig.unprivilegedPorts ? 8080 : 80 + port: insecurePort, + pathPrefix: bindPathPrefix }, proxyTo: { host: host, port: port } }); - proxy.call('bindHttp', { - pid: pid, - bindTo: { - host: proxyConfig.bindHost, - port: proxyConfig.unprivilegedPorts ? 4433: 443, - ssl: true - }, - proxyTo: { - host: host, - port: port - } + if (!proxyConfig.omitSsl) { + proxy.call('bindHttp', { + pid: pid, + bindTo: { + host: proxyConfig.bindHost, + port: securePort, + pathPrefix: bindPathPrefix, + ssl: true + }, + proxyTo: { + host: host, + port: port + } }); + } }; runWebAppServer(); diff --git a/tools/app.html.in b/tools/app.html.in index 63386289ed6..577c3c7e0b8 100644 --- a/tools/app.html.in +++ b/tools/app.html.in @@ -1,14 +1,14 @@ -{{#each stylesheets}} +{{#each stylesheets}} {{/each}} -{{#each scripts}} +{{#each scripts}} {{/each}} {{{head_extra}}}