Data Privacy

OSM Tile Proxy


OSM Tile Proxy is a proxy/tile cache (written in PHP) for openstreetmap tiles which also can modify the tiles on the fly to create custom colorful maps.

Originally written for the "Verbrannte Orte/Scorched Places" project around 2017, updated and slighlty re-wroed in March 2020.

How it works

OSM Tile Proxy fetches tiles from any openstreepmap compatible tile server and caches them locally to be served to any openlayers map. Additionally, OSm Tile proxy can modify the tiles to create new styles by adjusting color or saturation. Multiple different styles in parallel are possible.


You will need a webserver supporting PHP, including php-imagick (imagemagick).


  1. Clone the git repository
  2. Make sure cache/ and log/ are writable for your webserver
  3. Copy example/index.php-dist to public/
  4. Redirect all requests to index.php via your apache vhost or nginx host file.

Example for Apache:

          RewriteEngine on
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteRule . /index.php [L]
Example for nginx

    location /  {
            include /etc/nginx/fastcgi_params;
            fastcgi_param   SCRIPT_FILENAME  $document_root/index.php;
            fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;

Creating Styles - Examples

You can modify the tiles to create new map styles. There are three methods available: modulate, sepia and negate. You may also combine those methods, however the methods will always be executed in this order.

Example index.php with multiple styles:

    // create a style called "osm" with reduced saturation
    $style_osm = new \com\augmentedlogic\osmtileproxy\MapStyle("osm");
    $style_osm->setEffectModulate(100, 50, 100);

    // create a second style called "osmnight"
    $style_osmnight = new \com\augmentedlogic\osmtileproxy\MapStyle("osmnight");
    $style_osmnight->setEffectModulate(100, 50, 100);

    // add both styles to the proxy
    $tileproxy = new \com\augmentedlogic\osmtileproxy\TileProxy();

Standard OSM Tiles

Map with less Saturation

    $style_osm->setEffectModulate(100, 50, 100);


Night Mode

    $style_osm->setEffectModulate(100, 20, 100);


Grayscale and Negated

    $style_osm->setEffectModulate(100, 0, 100);


Sepia Style Map



Oversaturated Colors and Negated

    $style_osm->setEffectModulate(100, 160, 25);


Advanced Configuration

Setting the cache directory

   $tileproxy->setCacheDir(string $path_to_cache_dir>);
The directory under which tiles are cached.

Setting the log directory

   $tileproxy->setLogDir(string $path_to_log_dir);

The directory proxy.log is writen to.

Setting Log Levels

Available loglevels are LOGLEVEL_OFF, LOGLEVEL_INFO and LOGLEVEL_DEBUG. The default is LOGLEVEL_OFF.

Tile Refresh

Setting the time (in days) after which new tiles will be requested from the original tile server:

   setRefresh(int $days);

Browser Cache Expiry Time

Setting the Browser Cache Expiry Time (in hours):

   setBrowserCacheExpire(int $hours);   

Limit Referrer

   $tileproxy->setReferrer(string $referrer)
Tiles will only be served if the referrer matches this string. the default is NULL, i.e. referrer is not checked.


osm-tile-proxy is published under MIT License.


Hosted on

git clone