server = Bones.Server.extend({});

server.prototype.initialize = function(app) {
    this.config = app.config;
    this.use(this.hostInfo.bind(this));
};

// Middleware, retrieves host information from request headers and passes them
// to the rest of the stack at `req.uiHost` and `req.tileHost`.
server.prototype.removeTileSubdomain = function(host) {
    // If subdomain already exists on the request host, remove it.
    if (this.config.subdomains) {
        var subdomains = this.config.subdomains.split(',');
        var hostComponents = host.split('.');
        if (_.include(subdomains, hostComponents.shift())) {
           return hostComponents.join('.');
        }
    }
    return host;
};

server.prototype.hostInfo = function(req, res, next) {
    req.query.basepath = req.query.basepath || '/';
    if (req.headers && req.headers.host && !req.query.uiHost) {
        req.query.uiHost = 'http://' + req.headers.host;
        if (this.config.subdomains) {
            // Add subdomains for tiles.
            var basehost = this.removeTileSubdomain(req.headers.host);
            var subdomains = this.config.subdomains.split(',');
            req.query.tileHost = [];
            _.each(subdomains, function(subdomain) {
                req.query.tileHost.push('http://' + subdomain + '.' + basehost);
            });
        } else {
            // Use the same host for UI and tiles.
            req.query.tileHost = [ 'http://' + req.headers.host ];
        }
    }
    next();
};


@@ -803,16 +803,255 @@
 %7C%7C '/';%0A
+    if (!req.headers.host) %7B%0A        var address = req.socket.address();%0A        req.headers.host = address.address + ':' + address.port;%0A        var subdomains = false;%0A    %7D else %7B%0A        var subdomains = this.config.subdomains;%0A    %7D%0A%0A
     if (
@@ -1102,24 +1102,24 @@
 y.uiHost) %7B%0A
-
         req.
@@ -1163,16 +1163,16 @@
 s.host;%0A
+
         
@@ -1171,36 +1171,24 @@
         if (
-this.config.
 subdomains) 

allow connecting to IPs directly