TerriaMap can be deployed in almost any environment.
First, you may want to build a minified version of TerriaMap by running:
yarn gulp release
The normal build (
yarn gulp) can be deployed as well, but the release version is smaller and faster.
Then, you can host your TerriaMap using either the included Node.js-based web server, or by using any web server of your choosing.
Using the included Node.js-based web server
The easiest way to deploy your TerriaMap is to use the included Node.js-based web server, called terriajs-server. You'll need Node.js 14.0+ installed on the server in order to run terriajs-server.
Then, copy the following files and directories from your local system where you built TerriaMap onto the server:
node_modules(note: this can take a long time, be patient)
devserverconfig.jsonbut rename this to
productionserverconfig.json(and add any private access keys/passwords/secrets)
And on the server, change to the directory where you copied those files and directories and run:
NODE_ENV=production node ./node_modules/terriajs-server/terriajs-server.js --config-file productionserverconfig.json
The server will start on port 3001. You can specify a different port by adding
It is usually a good idea to run another web server, such as nginx on port 80 and then reverse-proxy to the Node.js server, rather than running terriajs-server on port 80 directly. NGINX is available as a package on Ubuntu via
sudo apt-get install -y nginx. Using a separate web server such as such as nginx will enable more security features, allow you to serve TerriaMap over HTTPS, and allow caching if you intend to setup Geoserver or other backend services.
Production ready TerriaMap
An example PM2 Ecosystem File can be found at
npm install -g pm2@latest
pm2 start deploy/ecosystem-example.config.js --update-env --env production
Using any web server
terriajs-server, described above, only does a few things:
- It includes a simple service at
/proxythat allows TerriaJS to access geospatial data servers that don't support CORS. If this service is not available, TerriaJS won't be able to access any datasets that are on other servers and that don't support CORS.
- When configured correctly, it persists blobs of JSON for use in the sharing feature. If this service is not available, the JSON can be stored in the share URL, instead. However, this makes for some extremely long URLs.
- If configured with
singlePageRoutingoptions it will serve up index.html for unmatched paths to allow for client side routes to be configured.
If points 2 - 4 above are not required, you can run your TerriaMap on virtually any web server by simply copying the TerriaMap
wwwroot onto the server!
You can also incrementally add these services to your own server, as necessary, by porting the code in terriajs-server to your environment.