TileMill on your Web server behind a reverse proxy

In the last version (0.9), TileMill has an additional dedicated process to serve the tiles. We had to change some bits of our server configuration.

Instead of documenting the new configuration in our internal Wiki, I prefered to share here a few technical lines (quite rough though).

We run TileMill inside a virtual machine on a server with reverse proxy rules.

Reverse Proxy configuration

Assuming your reach your TileMill virtual machine at tilemill.sillywalk.loc, with its two processes running (ports 20008 for tiles, 20009 for the application), your Apache reverse proxy configuration will be :

<VirtualHost *:80>
    ServerName tilemill.yourdomain.com

    ProxyPreserveHost On
    RewriteEngine on

    # Serve the tiles as /tiles/
    RewriteCond %{REQUEST_URI} ^(/tiles.*)$
    RewriteRule ^/tiles(.*) http://tilemill.sillywalk.loc:20008$1 [L,P]
    ProxyPassReverse /tiles http://tilemill.sillywalk.loc:20008/

    # Serve the application on /
    ProxyPass / http://tilemill.sillywalk.loc:20009/
    ProxyPassReverse / http://tilemill.sillywalk.loc:20009

TileMill configuration

Now that tiles and application ports are reachable respectively on http://tilemill.yourdomain.com/tiles and http://tilemill.yourdomain.com/, just tell TileMill to serve its pages accordingly in its configuration, /etc/tilemill/tilemill.config :

  "files": "/usr/share/mapbox",
  "server": true,
  "coreUrl": "tilemill.yourdomain.com:80",
  "tileUrl": "tilemill.yourdomain.com:80/tiles",
  "port": 20009,
  "listenHost": ""

Restart it...

sudo service tilemill restart

Done !

#tilemill, #apache, #howto - Posted in the Sys category