NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum


I have setup OSM server using mod-tiles and renderd. I want to implement key based access control to map tiles, something similar to Google map key. How can I do this?

asked 21 Jan '17, 09:02

Reshma%20Maner's gravatar image

Reshma Maner
accept rate: 0%


I need some more help in this, if somebody can guide me what exactly do I need to do if I want to implementing API Key based access control for mod-tiles.

my tileserver_site.conf file contains following lines which are commented.

AddTileConfig /folder/ TileSetName

How do I create APIs and use them for allowing map access?

(10 Jul '18, 12:31) Reshma Maner

There are many possible ways to do that. You could certainly add key handling directly to mod_tile if some C programming isn't too big a hurdle. Another option (but one that requires a config file reload on Apache every time the list changes) is to do this via Apache, either by creating one "AddTileConfig" directive per API key or by using somethig like mod_perl to generate these AddTileConfig rules programmatically, reading the keys from a file.

permanent link

answered 21 Jan '17, 22:18

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

edited 31 Mar '17, 17:38

Could you provide an example of 'creating one "AddTileConfig" directive per API key'?

(31 Mar '17, 17:06) rgwozdz

Sure: Instead of

AddTileConfig /tile mycoolmapstyle

which will lead Apache to map http://somehost/tile/z/x/y.png to tiles of your "mycoolmapstyle" type, you would

AddTileConfig /apikey1 mycoolmapstyle
AddTileConfig /apikey2 mycoolmapstyle
AddTileConfig /apikey3 mycoolmapstyle

and so on. These API keys, if long enough, cannot be guessed so they are "secret". Instead of the above, it is also possible to use mod_perl to read the API keys from a file and then generate the AddTileConfig directives.

(31 Mar '17, 17:38) Frederik Ramm ♦

Thanks very much, that really helps.

(31 Mar '17, 18:24) rgwozdz


If I add an apikey in tileserver_site.conf as given above, then what changes do I need to make in my OpenLayer code to access the map?

(24 Jul '17, 10:25) Reshma Maner

When creating the tile layer in OpenLayers you can specify the URL to use. In your case the URL would have to look like http://myserver/apikey1/${z}/${x}/${y}.png.

(24 Jul '17, 13:24) Frederik Ramm ♦

Hi, I dont understand how it works. Please, explain me. What means "mycoolmapstyle" in the example? I f i create a "/apikey1" i dont need create a symbolic link to /var/lib/mod_tile? Do you have an example of mod_perl and where i save this files?

Thank you.

permanent link

answered 10 May '18, 23:36

Flaviomx14's gravatar image

accept rate: 0%

edited 10 May '18, 23:38

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 21 Jan '17, 09:02

question was seen: 4,510 times

last updated: 10 Jul '18, 12:51

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum