8000 GitHub - dechristopher/lod at v0.5.0
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

dechristopher/lod

LOD: Levels of Detail

An intelligent map tile proxy cache for the edge.

Latest Release Stars Forks License: AGPL v3
Downloads
Build Status Docs Go Report Card
Coverage

LOD (Levels of Detail) is a thin map tile proxy with in-memory caching and a slim authentication backend. It will sit in front of any tile server and will aggressively cache tiles in memory, optionally storing them in a configured Redis cluster for faster fetching later. LOD is cluster-aware and uses Redis message queueing for intra-cluster communication when multiple instances are deployed together.

LOD is written in Go 1.17 using fiber. TOML is used for configuration. Go templates are used for templating. Internal in-memory caching is built upon the bigcache library by allegro.

Getting Started

Download a build from the releases page or just run:

$ go install github.com/tile-fund/lod@latest
Flags:
  --conf  Path to TOML configuration file. Default: config.toml
  --dev   Whether to enable developer mode. Default: false
  --debug Optional comma separated debug flags. Ex: foo,bar,baz
  --help  Shows this help menu.
Usage:
  lod [--conf config.toml] [--dev]

Or just use our Docker image!

You can create your own Dockerfile that adds a config.toml from the 8000 context into the config directory, like so:

FROM tilefund/lod:0.4.6
COPY /path/to/your_config.toml /opt/lod_cfg/config.toml
CMD [ "/opt/lod", "--conf", "/opt/lod_cfg/config.toml" ]

Alternatively, you can specify something along the same lines with Docker run options:

$ docker run -v /path/to/lod-config:/opt/lod_config -p 1337:1337 lod --conf /opt/lod_config/config.toml

Core Principles

v1.0 Feature Roadmap

  • Multi-level caching
    • In-memory, tunable LRU cache as first level
    • Redis cluster with configurable TTL as second level
  • Configurable header proxying and deletion
    • Content-Type and Content-Encoding added by default
  • Internal stats tracking
    • Hits, misses, hit-rate
    • Tiles per second (load averages)
    • Tile upstream fetch times (avg, 75th, 99th)
    • Expose Prometheus endpoint
  • Supports multiple configured tileserver proxies
    • Separate authentication (bearer tokens and CORS)
    • Separate internal cache instances per proxy
    • Allow configurable query parameters for tile URLs
      • Add to cache key for separate caching (osm/4/5/6/osm_id=19)
    • Separate stats tracking
  • Administrative endpoints
    • Reload the instance configuration
    • Flush the instance caches
    • Invalidate a given tile and re-prime it
    • Iteratively invalidate all tiles under a given tile (all zoom levels)
    • Iteratively prime all tiles under a given tile
    • Cluster-wide operations
      • Flush the instance caches across all instances
      • Invalidate a given tile and re-prime it across the cluster

Sample Config

[instance]
port = 1337 # port to bind to

[[proxies]]
# name of this proxy, available at http://lod/{name}/{z}/{x}/{y}.pbf
name = "osm"
# url of the upstream tileserver
tile_url = "https://tile.example.com/osm/{z}/{x}/{y}.pbf" 
# comma-separated list of allowed CORS origins
cors_origins = "https://example.com"
# auth bearer token to require for requests to upstream tileserver
access_token = "MyTilesArePrivate" 
# headers to pull and cache from the tileserver response
add_headers = [ "X-We-Want-This", "X-This-One-Too" ] 
# headers to delete from the tileserver response
del_headers = [ "X-Get-Rid-Of-Me" ]

[proxies.cache]
mem_cap = 100    # maximum capacity in MB of the in-memory cache
# Cache TTLs are set using Go's built-in time.ParseDuration
# Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
# For example: 1h, 5m, 300s, 1000ms, 2h35m, etc.
mem_ttl = "1h" # in-memory cache TTL
redis_ttl = "24h" # redis tile cache TTL, or "0" for no expiry
redis_url = "redis://localhost:6379/0" # redis connection URL
key_template = "{z}/{x}/{y}" # cache key template string, supports parameter names


# Supports many configured proxy instances for caching multiple tileservers
[[proxies]]
name = "another"
# etc.

License

LOD is licensed under the GNU Affero General Public License 3 or any later version at your choice. See COPYING for details.

More Tile Resources

Sponsor this project

 

Contributors 3

  •  
  •  
  •  
0