meteor/meteor — pull request #920 by tutukin (2013-04-06 16:00:55+00:00)
Title: Allow Meteor app to work behind a reverse proxy

# Testing environment

## Reverse proxy server
domain.com is an alias for localhost

var httpProxy = require('http-proxy');

httpProxy.createServer({
router : {
'domain.com/apps/todos/': 'localhost:3000/',
}
}).listen(4000);

With this configuration one should access the application via "http://domain.com:4000/todos/apps/", note the **slash** at the end of the URL!

## Meteor application

$ meteor create --example todos
$ cd todos
$ export ROOT_URL=http://domain.com:4000/apps/todos
$ meteor

# Fixes

1. Bundle.prototype._clientUrlsFor() uses the pathname part of the ROOT_URL (i.e. "/apps/todos" to calculate the urls of the files at the clientside.

2. DDL url defaults to the pathname part of the ROOT_URL (i.e. "/apps/todos")

"todos" application also needs some fixes:

1. todos/client/todos.css: all the url(...) should be fixed. I simply prepend "/apps/todos":
background: url("/apps/todos/close_16.png") no-repeat 0 center;

2. todos/client/todos.js: we should pass the root dir to the Backbone.history:
Meteor.startup(function () {
var root = '/' + Meteor.absoluteUrl().split(/\/+/).slice(2).join('/');
Backbone.history.start({pushState: true, root: root });
});