2

I am currently evaluating CartoDB(and really happy with it), and am trying to setup a proof of concept of a secure map.

I would like to implement a tile proxy, but really don’t know where to start.

I understand we can use this:

https://github.com/javisantana/cartodb-tiles-proxy a nd possibly node.js.

I am trying to create a map with an overlay that is accessed through some kind of web portal that users can filter polygons based on numerical sliders/web inputs.

It’s important that users can’t see the data in the tables.

Are there any guides out there?

2 Answers 2

4

Yes a proxy is the way to go right now, since you need to put your API_KEY in the url to access to tiles from private tables (and you should not expose your API_KEY).

The code is a bit outdated but it should work.

FYI we are currently testing an implementation that allows you to have maps from private tables, this is the spec: https://github.com/CartoDB/Windshaft-cartodb/wiki/Template-maps

It's not currently on production but it should be ready very soon

EDIT: It's already in production: https://github.com/CartoDB/docs/blob/gh-pages/maps_api.md

6
  • Thanks, could you please go into a little bit more detail on how to setup a proxy server? What kind of platform does it need to be run from?
    – user25558
    Jan 9, 2014 at 23:00
  • Basically it needs any linux flavor and nodejs > 0.8.11 installed. Then just follow readme steps. Jan 10, 2014 at 8:25
  • Thanks for your response, iv got Depian 7.3 installed on a VM, after following the instructions iv got Nodejs installs and added the module but when I try running it and start the proxy there I get an error from app.js. var proxy = new httpProxy.HttpProxy({ (new)TypeError: undefined is not a function Im a little bit out of my depth; on another forum they suggest changing the line to for another project. var proxy = new httpProxy.createProxyServer … but it doesn’t help much.
    – user25558
    Jan 21, 2014 at 3:03
  • Im still having issues getting the proxy server to start. Im running a clean install of Debian 7.3 on a VM, and Node.js V0.9.9. I have check that is grabbed the required modules: http-proxy and supergiant. Im getting an error: var proxy = new httpProxy.HttpProxy({ TypeError: undefined is not a function. Any ideas?
    – user25558
    Jan 23, 2014 at 23:15
  • @javisantana Is proxy still the way to go for this problem?
    – knutole
    Apr 24, 2014 at 13:50
2

Generally any site accessing CartoDB will make a series of different request types, some of these requests will be for tiles, others may be requests directly on the SQL API. These request types will have different URL patterns.

Your proxy must therefore handle these URL patterns accordingly and append the correct keys as per answer from @javisantana

I have used proxies for CartoDB written in a number of languages (.Net & Ruby) which do this and they are pretty straightforward to write and follow the same patterns as the node.js implementation referenced. However you should consider the performance overhead this approach can add and choose an implementation accordingly. I suggest the node.js solution would be a more suitable option if you had to include more advanced logic in your proxy.

Given that your proxy may also be doing something very simple i.e. a URL rewrite and appending the key, then a number of web servers have inbuilt facilities to perform this function. Here is an example from nginx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.