diff --git a/lib/modules/admin.js b/lib/modules/admin.js index 691fc4f..d22b168 100644 --- a/lib/modules/admin.js +++ b/lib/modules/admin.js @@ -1,3 +1,12 @@ +var adminDomains = [ + 'localhost.alpha.daplie.me' +, 'localhost.admin.daplie.me' +, 'alpha.localhost.daplie.me' +, 'admin.localhost.daplie.me' +, 'localhost.daplie.invalid' +]; +module.exports.adminDomains = adminDomains; + module.exports.create = function (deps, conf) { 'use strict'; @@ -43,20 +52,14 @@ module.exports.create = function (deps, conf) { */ ] }; - opts.sites.push({ - // greenlock: {} - $id: 'localhost.alpha.daplie.me' - , paths: [ - { $id: '/', modules: [ { $id: 'serve', paths: [ path.resolve(__dirname, '..', '..', 'admin', 'public') ] } ] } - , { $id: '/api/', modules: [ { $id: 'app', path: path.join(__dirname, 'admin') } ] } - ] - }); - opts.sites.push({ - $id: 'localhost.daplie.invalid' - , paths: [ - { $id: '/', modules: [ { $id: 'serve', paths: [ path.resolve(__dirname, '..', '..', 'admin', 'public') ] } ] } - , { $id: '/api/', modules: [ { $id: 'app', path: path.join(__dirname, 'admin') } ] } - ] + adminDomains.forEach(function (id) { + opts.sites.push({ + $id: id + , paths: [ + { $id: '/', modules: [ { $id: 'serve', paths: [ path.resolve(__dirname, '..', '..', 'admin', 'public') ] } ] } + , { $id: '/api/', modules: [ { $id: 'app', path: path.join(__dirname, 'admin') } ] } + ] + }); }); var app = require('../app.js')(deps, conf, opts); diff --git a/lib/modules/http.js b/lib/modules/http.js index 6d78a58..39c099e 100644 --- a/lib/modules/http.js +++ b/lib/modules/http.js @@ -51,7 +51,7 @@ module.exports.create = function (deps, conf, greenlockMiddleware) { var result = {}; lines.slice(1).forEach(function (line) { - var match = /(.*)\s*:\s*(.*)/.exec(line); + var match = /([^:]*?)\s*:\s*(.*)/.exec(line); if (match) { result[match[1].toLowerCase()] = match[2]; } else { @@ -186,8 +186,9 @@ module.exports.create = function (deps, conf, greenlockMiddleware) { var adminServer; function checkAdmin(conn, opts, headers) { - var admin = adminDomains.some(function (re) { - return re.test(headers.host); + var host = separatePort(headers.host).host; + var admin = require('./admin').adminDomains.some(function (domain) { + return host === domain; }); if (admin) {