feat(geoportal): nginx tile cache + PMTiles overview layers + tippecanoe pipeline
- Add nginx reverse proxy cache in front of Martin (2GB, 1h TTL, stale serving, CORS) - Martin no longer exposes host port — all traffic routed through tile-cache on :3010 - Add PMTiles support in map-viewer.tsx (conditional: NEXT_PUBLIC_PMTILES_URL env var) - When set: single PMTiles source for UAT + administrativ layers (z0-z14, ~5ms/tile) - When empty: fallback to Martin tile sources (existing behavior, zero breaking change) - Add tippecanoe Docker service (profiles: tools) for on-demand PMTiles generation - Add rebuild-overview-tiles.sh: ogr2ogr export → tippecanoe → MinIO atomic upload - Install pmtiles npm package for MapLibre protocol registration Performance impact: - nginx cache: 10-100x faster on repeat tile requests, zero PostGIS load on cache hit - PMTiles: sub-10ms overview tiles, zero PostGIS load for z0-z14 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
# nginx tile cache for Martin vector tile server
|
||||
# Proxy-cache layer: 10-100x faster on repeat requests, zero PostGIS load for cached tiles
|
||||
|
||||
proxy_cache_path /var/cache/nginx/tiles
|
||||
levels=1:2
|
||||
keys_zone=tiles:64m
|
||||
max_size=2g
|
||||
inactive=24h
|
||||
use_temp_path=off;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
# Health check
|
||||
location = /health {
|
||||
access_log off;
|
||||
return 200 "ok\n";
|
||||
add_header Content-Type text/plain;
|
||||
}
|
||||
|
||||
# Martin catalog endpoint (no cache)
|
||||
location = /catalog {
|
||||
proxy_pass http://martin:3000/catalog;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
# Tile requests — cache aggressively
|
||||
location / {
|
||||
proxy_pass http://martin:3000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
|
||||
# Cache config
|
||||
proxy_cache tiles;
|
||||
proxy_cache_key "$request_uri";
|
||||
proxy_cache_valid 200 1h;
|
||||
proxy_cache_valid 204 1m;
|
||||
proxy_cache_valid 404 1m;
|
||||
proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;
|
||||
proxy_cache_lock on;
|
||||
proxy_cache_lock_timeout 5s;
|
||||
|
||||
# Pass cache status header (useful for debugging)
|
||||
add_header X-Cache-Status $upstream_cache_status always;
|
||||
|
||||
# CORS headers for tile requests
|
||||
add_header Access-Control-Allow-Origin "*" always;
|
||||
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS" always;
|
||||
add_header Access-Control-Allow-Headers "Range, If-None-Match, Accept-Encoding" always;
|
||||
add_header Access-Control-Expose-Headers "Content-Range, Content-Length, ETag, X-Cache-Status" always;
|
||||
|
||||
# Handle preflight
|
||||
if ($request_method = OPTIONS) {
|
||||
add_header Access-Control-Allow-Origin "*";
|
||||
add_header Access-Control-Allow-Methods "GET, HEAD, OPTIONS";
|
||||
add_header Access-Control-Max-Age 86400;
|
||||
add_header Content-Length 0;
|
||||
return 204;
|
||||
}
|
||||
|
||||
# Martin already compresses — pass through
|
||||
proxy_set_header Accept-Encoding "";
|
||||
gzip off;
|
||||
|
||||
# Timeouts (Martin can be slow on low-zoom tiles)
|
||||
proxy_connect_timeout 10s;
|
||||
proxy_read_timeout 120s;
|
||||
proxy_send_timeout 30s;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user